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 

How to send NULL in a TField to database?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases
View previous topic :: View next topic  
Author Message
Reddog
Guest





PostPosted: Fri Dec 23, 2005 12:23 pm    Post subject: How to send NULL in a TField to database? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases 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.