I am trying to insert a re开发者_运维知识库cord through my application by calling a stored procedure. When the stored procedure is executed though, I'm getting the following error:
"Error converting data type nvarchar to datetime.Error converting data type nvarchar to datetime."
This error is only shown when I send a date, but if I trace each parameter and execute the SP directly from the database, it is executed perfectly without any errors. What might be the reason? I cannot post the code because it is spread across several layers.
How are you sending in the dates? Are you sending in a DateTime or are you sending in a formatted "date" string? If the later, look at the actual date string being sent in (hint: You can use SQL profiler to watch what is actually being sent in). Then try to run the stored procedure in SQL management studio. Most likely it will bomb due to your date format.
Solution (if I have the correct assumptions): Changing to an actual DateTime struct will solve your issue.
精彩评论