A
Alastair Williamson
Hi there,
I'm feeling kind of stupid that I can't work this one out for myself and I
hope someone can point me in the right direction.
I have an insert command that puts a selected Date into a smalldatetime
field in SQL Server 2000 (app is written in VB.NET vs2003). The situation
now exists that I need to insert a Null value into the field and I can't get
it to work. This is the code:
Dim nCmd as new SqlCommand("",nConn)
nCmd.CommandText = "INSERT INTO reps ([Reference],[DateRequired])
VALUES(@Reference,@DateReq)"
nCmd.Parameters.Add("@Reference",txtReference.Text)
If DateReq = True Then
nCmd.Parameters.Add("@DateReq",dtpDateReq.Value.Date)
Else
'Don't know what to put here!!!!
End IF
nCmd.ExecuteNonQuery()
If I pass a blank value it puts 1900.01.01 in the field. Can anyone tell me
how to get a Null value into the field.
Many thanks
C-Ya Aly
I'm feeling kind of stupid that I can't work this one out for myself and I
hope someone can point me in the right direction.
I have an insert command that puts a selected Date into a smalldatetime
field in SQL Server 2000 (app is written in VB.NET vs2003). The situation
now exists that I need to insert a Null value into the field and I can't get
it to work. This is the code:
Dim nCmd as new SqlCommand("",nConn)
nCmd.CommandText = "INSERT INTO reps ([Reference],[DateRequired])
VALUES(@Reference,@DateReq)"
nCmd.Parameters.Add("@Reference",txtReference.Text)
If DateReq = True Then
nCmd.Parameters.Add("@DateReq",dtpDateReq.Value.Date)
Else
'Don't know what to put here!!!!
End IF
nCmd.ExecuteNonQuery()
If I pass a blank value it puts 1900.01.01 in the field. Can anyone tell me
how to get a Null value into the field.
Many thanks
C-Ya Aly