insert dbnull

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
Is it possbile to send a DBNull back to the database?

When a record is marked as "complete", it records the current date and places it in the DB under DateComplete.

However, that record can be reactivated at anytime, and once it's reactivated I want the DateComplete field to be null again.

...probably a noob question, I just haven't got my programming head on today and I'm trying to tie up all loose ends with my app :rolleyes:
 
YEs and no..... depending on the DB type, you can't set NULL values to a DAteTime field (you can, but it's going to translate it to something else.... SQL Server sees it as 12/31/1899 -- go figure)....

-tg
 
I had the same issue when re-opening one of my closed records. I use ComponentOne's date edit component. It allow me to set C1DateEdit1.value to dbnull.value and when it is bound to the dataset it effectively sends null to the database.
Have you tried binding the date field to a textbox and then clearing the textbox
"TextBox1.clear" then updating the dataset. I'd be willing to bet it won't work, but it might be worth a try.
 
I might check out that component

Previously I would put a checkbox on the DTP, and add an event handler that set the datasource's value to DBNull/Value depending on the checked state.. HUGLY, man! HUGLY!
 
Back
Top