开发者

Data can be inserted directly from SP but fails if the SP is called from the application

开发者 https://www.devze.com 2023-04-07 16:41 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消