Hi,
Here's my problem.
So using a stored proc and some parameters I want to update a datetime field
So I define @.theDate as datetime in my stored proc
in my vb.net app I have
dbcmd.Parameters.AddWithValue("@.theDate", SelectedDate)
where SelectedDate is
Dim SelectedDate as Nullable(of Datetime)
Now if SelectDate is a value all is good with the world.
However if SelectDate is Null I get an error.
How do I pass a null date to the stored proc ?
You need to add code like this:
dbcmd.Parameters.AddWithValue("@.theDate", (SelectedDate==null) ? DbNull.Value : SelectedDate)
DbNull.Value is a null for the database.
No comments:
Post a Comment