G
Guest
Hi,
I want to update ACCESS database, the field Date (DateTime format). I used
the following code:
DateTime dt;
string strInsertShift = "INSERT INTO MyTable (Date) values (@dt)";
OleDbCommand cmdS = new OleDbCommand(strMyDb, conn);
cmdS.Parameters.Add(new OleDbParameter("@dt", OleDbType.DBDate));
cmdS.Parameters["@dt"].Value = new DateTime(2004, 09, 01);
conn.Open();
int rowsReturnedS = cmdS.ExecuteNonQuery();
conn.Close();
I get the exception message: Syntax error in INSERT INTO statement.
I guess the problem is with the DateTime field, as when I use similar code
for other field with string values, it works fine.
Any suggestion, what is wrong?
Thanks,
Lubomir
I want to update ACCESS database, the field Date (DateTime format). I used
the following code:
DateTime dt;
string strInsertShift = "INSERT INTO MyTable (Date) values (@dt)";
OleDbCommand cmdS = new OleDbCommand(strMyDb, conn);
cmdS.Parameters.Add(new OleDbParameter("@dt", OleDbType.DBDate));
cmdS.Parameters["@dt"].Value = new DateTime(2004, 09, 01);
conn.Open();
int rowsReturnedS = cmdS.ExecuteNonQuery();
conn.Close();
I get the exception message: Syntax error in INSERT INTO statement.
I guess the problem is with the DateTime field, as when I use similar code
for other field with string values, it works fine.
Any suggestion, what is wrong?
Thanks,
Lubomir