Using DateTime in a SqlParameter for Stored Procedure, format error

后端 未结 4 1261
予麋鹿
予麋鹿 2020-11-27 20:04

I\'m trying to call a stored procedure (on a SQL 2005 server) from C#, .NET 2.0 using DateTime as a value to a SqlParameter. The SQL type in the s

4条回答
  •  盖世英雄少女心
    2020-11-27 20:49

    Here is how I add parameters:

    sprocCommand.Parameters.Add(New SqlParameter("@Date_Of_Birth",Data.SqlDbType.DateTime))
    sprocCommand.Parameters("@Date_Of_Birth").Value = DOB
    

    I am assuming when you write out DOB there are no quotes.

    Are you using a third-party control to get the date? I have had problems with the way the text value is generated from some of them.

    Lastly, does it work if you type in the .Value attribute of the parameter without referencing DOB?

提交回复
热议问题