Re: datetime type in SQL Server 2008



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.





.



Relevant Pages

  • datetime type in SQL Server 2008
    ... TEMPLATES table has a field X_UPDATED whose type is datetime. ... OdbcParameter param = cmd.Parameters.Add("FILEDATA", ... It looks like the OdbcType.DateTime doesn't match SQL Server 2008's ... sql server 2005 doesn't throw this exception. ...
    (microsoft.public.dotnet.languages.csharp)
  • DateTime type in SQL Server 2008
    ... TEMPLATES table has a field X_UPDATED whose type is datetime. ... Fractional second precision exceeds the scale specified in the parameter ... It looks like the OdbcType.DateTime doesn't match SQL Server 2008's ... sql server 2005 doesn't throw this exception. ...
    (comp.databases.ms-sqlserver)
  • Re: datetime type in SQL Server 2008
    ... code to update it in SQL Server 2008 but an exception occurs. ... OdbcParameter param = cmd.Parameters.Add("FILEDATA", ... So the Odbc driver tries to assign to the X_UPDATED field which is of type ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DateTime type in SQL Server 2008
    ... Fractional second precision exceeds the scale specified in the parameter ... It looks like the OdbcType.DateTime doesn't match SQL Server 2008's ... How should I change my code to update the datetime field in ... sql server 2005 doesn't throw this exception. ...
    (comp.databases.ms-sqlserver)
  • Re: ASP.NET 2.0 - a newbie question
    ... the exception can be identified using the exception stack trace below. ... established connection failed because connected host has failed to ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ... Microsoft SQL Server? ...
    (microsoft.public.dotnet.framework.aspnet)

Loading