开发者

ASP.NET GridView throws: The version of SQL Server in use does not support datatype 'date'

How to deal with a server that doesn't support 'date'? Sorry for such a vague question. Please let me know what addtional details I should add. Thanks.

Here's the error:

Server Error in '/' Application.

The version of SQL Server in use does not support datatype 'date'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where 开发者_如何转开发it originated in the code.

Exception Details: System.ArgumentException: The version of SQL Server in use does not support datatype 'date'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


For the Column Properties from the server explorer, I've specified the column as a datetime, so I'm not sure why the auto generated ASP.NET gridview is trying to work with a date type as opposed to a datetime type.

ASP.NET GridView throws: The version of SQL Server in use does not support datatype 'date'

Here's the code auto-generated by the ASP.NET 2.0 grid view that is causing the error:

ASP.NET GridView throws: The version of SQL Server in use does not support datatype 'date'

Is it okay to just change DbType="Date" to DbType="Datetime"? (It seems to work.)


Most likely you are looking for either the datetime or smalldatetime type:

Date and time data types for representing date and time of day


You could also create a user-defined type based on DateTime that always has a time component equal to 0 (aka midnight).


SQL Server pre-2008 does not support just DATE like Oracle (and some other RDBMS).

You are probably looking at DateTime or SmallDateTime

Most of us use either one of those - we just leave the time part as 00:00:00.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜