T
tshad
I have the following code:
***************************************************************************
Dim CommandText as String = "INSERT INTO ftsolutions.dbo.position
(client,dateposted) VALUES ( @client,@dateposted)"
Dim objCmd as New SqlCommand(CommandText,objConn)
with objCmd.Parameters
.Add("@client",SqlDbType.Char,50).value = "the companies next test"
.Add("@dateposted",SqlDbType.datetime).value = dateposted.text
end with
objCmd.ExecuteNonQuery
****************************************************************************
My problem is that if the dateposted.text is blank, then I get an error
saying date is invalid. If I take out the dateposted line all together (as
well as in the insert statement), it uses todays date - which is what I want
as I have getdate() as the default.
How do I use a parameter and allow it to be null so it takes the default?
Thanks,
Tom.
***************************************************************************
Dim CommandText as String = "INSERT INTO ftsolutions.dbo.position
(client,dateposted) VALUES ( @client,@dateposted)"
Dim objCmd as New SqlCommand(CommandText,objConn)
with objCmd.Parameters
.Add("@client",SqlDbType.Char,50).value = "the companies next test"
.Add("@dateposted",SqlDbType.datetime).value = dateposted.text
end with
objCmd.ExecuteNonQuery
****************************************************************************
My problem is that if the dateposted.text is blank, then I get an error
saying date is invalid. If I take out the dateposted line all together (as
well as in the insert statement), it uses todays date - which is what I want
as I have getdate() as the default.
How do I use a parameter and allow it to be null so it takes the default?
Thanks,
Tom.