| View previous topic :: View next topic |
| Author |
Message |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Aug 28, 2003 7:47 am Post subject: Re: Property Editor for DataField of a data aware vcl |
|
|
"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
|
Posted: Fri Aug 29, 2003 12:16 am Post subject: Re: Property Editor for DataField of a data aware vcl |
|
|
| 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
|
Posted: Fri Aug 29, 2003 2:49 am Post subject: Re: Property Editor for DataField of a data aware vcl |
|
|
"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
|
Posted: Fri Aug 29, 2003 3:50 am Post subject: Re: Property Editor for DataField of a data aware vcl |
|
|
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
|
Posted: Fri Aug 29, 2003 6:26 am Post subject: Re: Property Editor for DataField of a data aware vcl |
|
|
"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
|
Posted: Fri Aug 29, 2003 6:38 am Post subject: Re: Property Editor for DataField of a data aware vcl |
|
|
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 |
|
 |
|