EDN Admin
Well-known member
TEMPLATES table has a field X_UPDATED whose type is datetime. I use the code<br/> to update it in SQL Server 2008 but an exception occurs.<br/> <br/> <br/>
<pre lang="x-c# OdbcCommand cmd = new OdbcCommand("UPDATE TEMPLATES SET X_UPDATED=? WHERE FILENAME=" + fileName + "", this._dbConn);
OdbcParameter param2 = cmd.Parameters.Add("X_UPDATED",
OdbcType.DateTime);
param2.Value = DateTime.Now; // Exception
cmd.ExecuteNonQuery();[/code]
<br/> <br/> <br/> <br/> The exception is : System.Data.Odbc.OdbcException: ERROR [22008]<br/> [Microsoft][SQL Server Native Client 10.0]Datetime field overflow.<br/> Fractional second precision exceeds the scale specified in the parameter<br/> binding. <br/> <br/> It looks like the OdbcType.DateTime doesnt match SQL Server 2008s<br/> datetime. How should I change my code to update the datetime field in<br/> sqlserver 2008? Thanks.<br/> <br/> BTW, sql server 2005 doesnt throw this exception.
View the full article
<pre lang="x-c# OdbcCommand cmd = new OdbcCommand("UPDATE TEMPLATES SET X_UPDATED=? WHERE FILENAME=" + fileName + "", this._dbConn);
OdbcParameter param2 = cmd.Parameters.Add("X_UPDATED",
OdbcType.DateTime);
param2.Value = DateTime.Now; // Exception
cmd.ExecuteNonQuery();[/code]
<br/> <br/> <br/> <br/> The exception is : System.Data.Odbc.OdbcException: ERROR [22008]<br/> [Microsoft][SQL Server Native Client 10.0]Datetime field overflow.<br/> Fractional second precision exceeds the scale specified in the parameter<br/> binding. <br/> <br/> It looks like the OdbcType.DateTime doesnt match SQL Server 2008s<br/> datetime. How should I change my code to update the datetime field in<br/> sqlserver 2008? Thanks.<br/> <br/> BTW, sql server 2005 doesnt throw this exception.
View the full article