D
Dinko Deranja
I have the following statement (mycommand is SQLClient.SQLCommand):
mycommand.commandtext = "INSERT INTO myTable (mysmalldatetime) VALUES
(@mysmalldatetime)"
mycommand.Parameters.Add("@mysmalldatetime", SQLDBType.SmallDateTime,
4).Value = IIf (startDate.Text <> "", startDate.Text, DBNull.Value)
If user enters startDate in textbox then it works, but if the textbox is
empty, then the error message says (at mycommand.executenonquery()):
Input string was not in a correct format.
The question is - how to insert the null value in this smalldatetime field?
mycommand.commandtext = "INSERT INTO myTable (mysmalldatetime) VALUES
(@mysmalldatetime)"
mycommand.Parameters.Add("@mysmalldatetime", SQLDBType.SmallDateTime,
4).Value = IIf (startDate.Text <> "", startDate.Text, DBNull.Value)
If user enters startDate in textbox then it works, but if the textbox is
empty, then the error message says (at mycommand.executenonquery()):
Input string was not in a correct format.
The question is - how to insert the null value in this smalldatetime field?