Hi,
I'm getting an error when I try to update a field of type Timestamp using a command and parameters.
StringBuilder myQuery = new StringBuilder("UPDATE myschema.mytable " +
"SET last_time = @last_time");
PgSqlCommand pgCmd = new PgSqlCommand(myQuery.ToString(), _pgConnection_Main);
pgCmd.Parameters.Add("@last_time", PgSqlType.TimeStamp).Value = DateTime.Now;
pgCmd.ExecuteNonQuery();
I get the error "date/time field value out of range"
However, if I try, for example:
StringBuilder myQuery = new StringBuilder("UPDATE myschema.mytable " +
"SET last_time = '2006-08-25 13:51'::timestamp");
PgSqlCommand pgCmd = new PgSqlCommand(myQuery.ToString(), _pgConnection_Main);
pgCmd.ExecuteNonQuery();
Everything works fine in this case. Any ideas what's wrong when I use parameters? I have tried
pgCmd.Parameters.Add("@last_time", PgSqlType.TimeStamp).Value = DateTime.Now;
and
pgCmd.Parameters.Add("@last_time", PgSqlType.TimeStampTZ).Value = DateTime.Now;
but I still get the problem.
I'm using
PostgreSQLDirect .NET Data Provider 2.40.13.0
and the DB is PostgreSQL 8.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5 (Debian 1:3.3.5-13)
Thanks.