views:

305

answers:

3

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.

alt text

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

alt text

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

+3  A: 

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

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

Andrew Hare
Is it okay to just change DbType="Date" to DbType="Datetime"?
Adam Kane
Yes, that is fine.
Andrew Hare
Thanks. DbType="Datetime" is working.
Adam Kane
A: 

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

No Refunds No Returns
I would recommend against creating custom data types. Lots of articles on why this is not such a good idea. Also UDTs may be discontinued in the future.
Raj More
It may rain tomorrow too.
No Refunds No Returns
A: 

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.

Raj More
Is it okay to just change DbType="Date" to DbType="Datetime"?
Adam Kane
@Raj: SQL Server 2008 does have a `DATE` type. Earlier versions don't.
LukeH
@Adam Kane: Yes changing to `DateTime` should work
Raj More