Showing posts with label outcome. Show all posts
Showing posts with label outcome. Show all posts

Sunday, March 11, 2012

Error converting data type varchar to datetime.

Hi,

It is not exactly what I stated in the subject - It's an outcome - exception thrown while executing non-query command.

I get this exception when I try to execute my stored procedure that takes datetime as one of its parameters.

I am using dataset designer to create table adapters and build queries. Then I simply use objectdatasource component that uses one of the table adapters and bind it to for example a detailsview control.

When I run this in debug mode and trace the objects everything looks perfect including these datetime parameters. It is sql server that throws the exception. I ran the sql profiler to see what exactly is going on, and I captured the command that is sent by ADO - it's broken into several lines right in the middle of my datetime parameters... this is the source of the problem. Everything is working fine when I take this command and execute it as a single line in the sql management studio.

Is there anything about ADO that I do not know?

Is the error only with that particular SQL statement or anyother query with date? What datatype you are passing to the stored procedure? DateTime or varchar?

Thanks

|||

Are you passing date as string ? Are you sure that you date format is the same as default date format on SQL server?

If your date is not in valid format for SQL you can have this kind of problems.

Thanks