ADO.NET won't accept null dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

using "Imports System.Data.odbc", I'm using textbox "text" property to insert a new record into te dataset. If the date textbox is empty the dataset won't accept the value. How do I insert a null into the dataset field?
 
Hi Bob,

When inserting a NULL record, use DbNull.Value. (Since you are using a
textbox, an empty value is "", not NULL, and a DateTime data type must be
either a date/time or explicitly NULL.) Does this help you?

Take care,

Eric

Bob said:
using "Imports System.Data.odbc", I'm using textbox "text" property to
insert a new record into te dataset. If the date textbox is empty the
dataset won't accept the value. How do I insert a null into the dataset
field?
 
Dim DeathDate as Object
If txtDeathDate.Text Is Nothing then
DeathDate = System.DBNull.Value
end if

insert statement writes value in DeathDate, not txtDeathDate.Text

HTH
Dean Slindee
Bob said:
using "Imports System.Data.odbc", I'm using textbox "text" property to
insert a new record into te dataset. If the date textbox is empty the
dataset won't accept the value. How do I insert a null into the dataset
field?
 
Back
Top