B
Brane Brodnik
I have data field MyTime of type Date/Time in MS Access table Test. I want
to add record into this table with value passed as parameter.
I do the following in C#:
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = MyConnection;
cmd.CommandText = "INSERT INTO Test (MyTime) VALUES(?);";
cmd.Parameters.Add("MyTime", DateTime.Now);
cmd.ExecuteNonQuery();
Last statement throws an exception with message
"Data type mismatch in criteria expression."
If I pass only date part to parameter, for example:
cmd.Parameters.Add("MyTime", DateTime.Today);
it works fine.
How can I create and use parameter that wold pass both date and time parts
to date/time field?
to add record into this table with value passed as parameter.
I do the following in C#:
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = MyConnection;
cmd.CommandText = "INSERT INTO Test (MyTime) VALUES(?);";
cmd.Parameters.Add("MyTime", DateTime.Now);
cmd.ExecuteNonQuery();
Last statement throws an exception with message
"Data type mismatch in criteria expression."
If I pass only date part to parameter, for example:
cmd.Parameters.Add("MyTime", DateTime.Today);
it works fine.
How can I create and use parameter that wold pass both date and time parts
to date/time field?