SQL Server 2005 sees DateTime sproc parameter with 12:00 PM for time when only short date set on parameter
Had a weird issue yesterday with a .NET 3.5 application.
We have a web service that calls a stored procedure for search results. One of the parameters is a date. The parameter value is a short date string (M/d/yyyy, en-us) and its type is DbType.DateTime. I am using DbProviderFactory connecting to SQL Server 2005, so the paramater type actually becomes SqlDbType.DateTime.
Normally, when I use SQL Server Profiler to watch the call, I see the date as "yyyy-M-d 00:00:00". But, yesterday, I was profiling due to some reported issues and the date appeared as "yyyy-M-d 12:00:00:000". Basically, everything has always worked as intended and then, without a change to my code, the stored procedure was seeing 12:00 PM.
This also happened on some inserts and updates causing 12PM to get stored with some default dates instead of 12AM, midnight.
Without updating my code, all is well today.
I can see that when the DataAdapter fills my DataTable, a CoercedValue property gets set on the parameter as "yyyy-M-d 12:00:00 AM" while the Value is only "M/d/yyyy".
So, my question is:
Does anyone know enough about the DataAdapter (DbDataAdapter or SqlDataAdapter) to know why it would be sending 12PM when I've only specified the short date as the value for the stored procedure parameter?
Thanks in advan开发者_如何转开发ce!
精彩评论