SkydivingSteve
Technical User
Using C# / ASO.Net to create a record in Access. I'm having problems figuring out the syntax to add today's date into a date field in Access. The error message I'm getting is "Data type mismatch in criteria expression. " and the line flagged is "objCmd.ExecuteNonQuery();"
Any thoughts appreciated! Code follows;
[tt]
string strCmd;
string SQLtext;
SQLtext="INSERT INTO BlahTable (ordered_by_name, heading, entered_date) VALUES (@name, @heading, @entered_date)";
objCmd = new OleDbCommand(SQLtext, objConn);
objCmd.Parameters.Add("@name", Name.Text);
objCmd.Parameters.Add("@heading", Heading.Text);
objCmd.Parameters.Add("@entered_date", DateTime.Now);
objConn.Open();
objCmd.ExecuteNonQuery();
[/tt]
Any thoughts appreciated! Code follows;
[tt]
string strCmd;
string SQLtext;
SQLtext="INSERT INTO BlahTable (ordered_by_name, heading, entered_date) VALUES (@name, @heading, @entered_date)";
objCmd = new OleDbCommand(SQLtext, objConn);
objCmd.Parameters.Add("@name", Name.Text);
objCmd.Parameters.Add("@heading", Heading.Text);
objCmd.Parameters.Add("@entered_date", DateTime.Now);
objConn.Open();
objCmd.ExecuteNonQuery();
[/tt]