BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: Property Editor for DataField of a data aware vcl

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Aug 28, 2003 7:47 am    Post subject: Re: Property Editor for DataField of a data aware vcl Reply with quote




"Azrin Aris" <azrin (AT) rndtm (DOT) net.my> wrote


Quote:
1. The DataField property has no property editor, meaning
that I cannot list out the fields of the selected DataSet. I have
to type in manually. Do I need to register the property editor
manually if that is the case, what is the class name of the
property editor?

Look for TDataFieldProperty declared in dbreg.hpp.

Quote:
2. When the component is assigned to a field that is NULL, it
gives me an exception - EConvert Error.

That is probably just a bug in your own code simply not looking for invalid
values before trying to use them.


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03




Back to top
Azrin Aris
Guest





PostPosted: Fri Aug 29, 2003 12:16 am    Post subject: Re: Property Editor for DataField of a data aware vcl Reply with quote




Quote:
Look for TDataFieldProperty declared in dbreg.hpp.
Thank you



Quote:
2. When the component is assigned to a field that is NULL, it
gives me an exception - EConvert Error.


That is probably just a bug in your own code simply not looking for invalid
values before trying to use them.
I got the same thing when using TDBEdit.


Here is some info. I use BCB6 with MySQL. The field that the component
links to is of the type of Date in MySQL. The error it gives is EConvert
Error - "0.0' is not a valid timestamp' - this is the exact quote (the
single and double qoute) from the error message.

Regards,
Azrin



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Aug 29, 2003 2:49 am    Post subject: Re: Property Editor for DataField of a data aware vcl Reply with quote




"Azrin Aris" <azrin (AT) rndtm (DOT) net.my> wrote


Quote:
Here is some info. I use BCB6 with MySQL. The field that
the component links to is of the type of Date in MySQL. The
error it gives is EConvert Error - "0.0' is not a valid timestamp'
- this is the exact quote (the single and double qoute) from the
error message.

That does not tell me anything without seeing your actual code for using the
field. That error does not pop up on its own, you have to do something with
the field first that then triggers it.


Gambit



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03




Back to top
Azrin Aris
Guest





PostPosted: Fri Aug 29, 2003 3:50 am    Post subject: Re: Property Editor for DataField of a data aware vcl Reply with quote

Remy Lebeau (TeamB) wrote:
Quote:

That does not tell me anything without seeing your actual code for using the
field. That error does not pop up on its own, you have to do something with
the field first that then triggers it.


Sorry, here is the code:

void __fastcall TDBDateTimePicker::DataChange( TObject* Sender)
{
if(FDataLink->Field == NULL) // if no field is assigned ...
{
DateTime = 0;
}
else //otherwise, set to new data
{
DateTime = FDataLink->Field->AsDateTime;
}
}



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Aug 29, 2003 6:26 am    Post subject: Re: Property Editor for DataField of a data aware vcl Reply with quote


"Azrin Aris" <azrin (AT) rndtm (DOT) net.my> wrote

Quote:
DateTime = FDataLink->Field->AsDateTime;

You are not testing the field for a NULL data value before trying to convert
the value. TField has an IsNull property for that purpose, ie:

if( FDataLink->Field->IsNull )
DateTime = 0;
else
DateTime = FDataLink->Field->AsDateTime;

If you want to be even more cautious, you can test the DataType property as
well to make sure the field really is a DateTime before using the AsDataType
property:

void __fastcall TDBDateTimePicker::DataChange( TObject* Sender)
{
if( FDataLink->Field )
{
if( !FDataLink->Field->IsNull )
{
if( FDataLink->Field->DataType == ftDateTime )
{
DateTime = FDataLink->Field->AsDateTime;
return;
}
}
}

DateTime = 0;
}


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03




Back to top
Azrin Aris
Guest





PostPosted: Fri Aug 29, 2003 6:38 am    Post subject: Re: Property Editor for DataField of a data aware vcl Reply with quote

Remy Lebeau (TeamB) wrote:
Quote:
"Azrin Aris" <azrin (AT) rndtm (DOT) net.my> wrote in message
news:3f4ecd7e$1 (AT) newsgroups (DOT) borland.com...

DateTime = FDataLink->Field->AsDateTime;


You are not testing the field for a NULL data value before trying to convert
the value. TField has an IsNull property for that purpose, ie:

if( FDataLink->Field->IsNull )
DateTime = 0;
else
DateTime = FDataLink->Field->AsDateTime;

If you want to be even more cautious, you can test the DataType property as
well to make sure the field really is a DateTime before using the AsDataType
property:

void __fastcall TDBDateTimePicker::DataChange( TObject* Sender)
{
if( FDataLink->Field )
{
if( !FDataLink->Field->IsNull )
{
if( FDataLink->Field->DataType == ftDateTime )
{
DateTime = FDataLink->Field->AsDateTime;
return;
}
}
}

DateTime = 0;
}


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03


Thanks Remy, I'll let you know the result after I modify my code.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.