 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Reddog Guest
|
Posted: Fri Dec 23, 2005 5:23 pm Post subject: How to send NULL in a TField to database? |
|
|
Hi all,
I want to send a NULL in a TField, (called 'update' and defined as a
column of type TIMESTAMP - I am using MySQL) - this should result in
the current MySQL server timestamp being entered into the table.
From the MySQL command prompt this is fine ie I can either ignore the
column or set it to NULL and it is timestamped in the table ok.
But I cannot get the BCB TField to accept a NULL, I get
EDatabaseError exception "Field 'update' must have a value".
In the BeforePost event I removed the faRequired from the TTable
DataSet attribute set, expecting BCB not to send the 'update' field,
but although the removal works the result is still an exception, eg
void resetRequired ( TDataSet *DataSet) {
TFieldDef *fd = DataSet->FieldDefs->Find("update");
if ( fd) {
if ( fd->Attributes.Contains(faRequired) ) {
TFieldAttributes ss;
ss << faRequired;
fd->Attributes -= ss;
}
}
}
Any ideas on how to get BCB to either
a) not send the field or
b) to accept NULL?
I am hoping that I have just missed a setting somewhere!!!
Oh and by the way :
1) I do not want to remove the field from the BCB dataset as I
want to see the value it contains when I refresh - thus indicating the
last update of the record etc.
2) and I do not want to use a TQuery (ie not setting the 'update
field) as this would entail SQL coding for each table with an 'update'
field.
Thanks,
Reddog. |
|
| Back to top |
|
 |
Thomas J. Junior Member
Joined: 17 Mar 2006 Posts: 15
|
Posted: Thu Apr 06, 2006 10:42 am Post subject: re:How to send NULL in a TField to database? |
|
|
The method Clear() of the TField does it _________________ C++ Builder 6, DevExpress, MyDac, TsiLang, MySQL |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Apr 25, 2006 9:03 pm Post subject: Re: How to send NULL in a TField to database? |
|
|
pField->Clear(); |
|
| Back to top |
|
 |
|
|
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
|
|