views:

423

answers:

2

When trying to execute an Insert comment using the Insert CLass I get the following Exception:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

I am uing the following globalization settings:

<globalization uiCulture="en-AU" culture="en-AU"/>

And my date format is :"dd/mm/YYYY"

I can workaround the exception using:

ci.Date.HasValue?ci.Date.Value.ToString("yyyy-MM-dd HH:mm:ss"):null

But this is ugly as...is there something I can do so subsonic picks my globalization settings?

Thanks

Luis

A: 

Are you using a SQLServer 2008 "Date" column?

Im seeing the same problem with this scenario and in my case its because the Subsonic class property for SQL Server "Date" types is being set to "String".

See http://stackoverflow.com/questions/784716/subsonic-2-2-generated-property-for-sql-server-2008-date

If you can confirm this, I'd appreciate it, and I will post an issue to the Subsonic project issues list.

Zapatta
A: 

Luis you should post some code so that we can see exaclty what you are trying to do but I think I know the issue.

If you pass in a datatype that Subsonic does not recognize such as a DateTime?(as opposed to Date) then subsonic is going to call the ToString() method of the object and set its DataType to string which would cause the issue you mention above. You should be able to just pass ci.Date.Value without having to call your own ToString("format") method.

runxc1 Bret Ferrier