Re: datetime type in SQL Server 2008
- From: "yqever" <yqever@xxxxxxx>
- Date: Mon, 28 Sep 2009 17:06:41 +0800
Thanks guys.
No exception occurs after truncating the milliseconds of DateTime.
"yqever" <yqever@xxxxxxx> wrote in message
news:eaNX$N%23PKHA.1796@xxxxxxxxxxxxxxxxxxxxxxx
TEMPLATES table has a field X_UPDATED whose type is datetime. I use the
code to update it in SQL Server 2008 but an exception occurs.
cmd = new OdbcCommand("UPDATE TEMPLATES SET X_UPDATED=?
WHERE FILENAME='" + fileName + "'", this._dbConn);
OdbcParameter param = cmd.Parameters.Add("FILEDATA",
OdbcType.VarBinary);
param.Value = data;
OdbcParameter param2 = cmd.Parameters.Add("X_UPDATED",
OdbcType.DateTime);
param2.Value = updatedTime; // Exception
cmd.ExecuteNonQuery();
The exception is : System.Data.Odbc.OdbcException: ERROR [22008]
[Microsoft][SQL Server Native Client 10.0]Datetime field overflow.
Fractional second precision exceeds the scale specified in the parameter
binding.
It looks like the OdbcType.DateTime doesn't match SQL Server 2008's
datetime. How should I change my code to update the datetime field in
sqlserver 2008? Thanks.
BTW, sql server 2005 doesn't throw this exception.
.
- Follow-Ups:
- Re: datetime type in SQL Server 2008
- From: Mark Rae [MVP]
- Re: datetime type in SQL Server 2008
- References:
- datetime type in SQL Server 2008
- From: yqever
- datetime type in SQL Server 2008
- Prev by Date: Re: datetime type in SQL Server 2008
- Next by Date: Re: datetime type in SQL Server 2008
- Previous by thread: Re: datetime type in SQL Server 2008
- Next by thread: Re: datetime type in SQL Server 2008
- Index(es):
Relevant Pages
|
Loading