Unable to store empty/null date in SQL Sever 2000 date/time field via VB.Net Form

H

Henry

I have built a vb.net form that contains a text box that is used to
store a date field that is input by the user. The form updates work fine
when the textbox is populated with a date. However, when the date field
is set to empty/nothing by the user (which is a valid condition), the
update fails e.g. (Cast from type 'DBNull' to type 'String' is not
valid)

I’ve tried setting the form date field to vbnull, dbnull.value, “ “ ,
etc. with no luck.

Any ideas on how I can resolve this are much appreciated.
 
H

Herfried K. Wagner [MVP]

* Henry said:
I have built a vb.net form that contains a text box that is used to
store a date field that is input by the user. The form updates work fine
when the textbox is populated with a date. However, when the date field
is set to empty/nothing by the user (which is a valid condition), the
update fails e.g. (Cast from type 'DBNull' to type 'String' is not
valid)

\\\
If ... Is DBNull.Value Then
...
Else
... = ...
End If
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top