S.CTN
S.CTN

Reputation: 15

c# Updating datetime column in access

OleDbConnection con = new OleDbConnection(@constring);
con.Open();
string cmdstring = "UPDATE table SET date=" + DateTime.Parse(datetxt.Text) +" WHERE id ="+id;
OleDbCommand cmd = new OleDbCommand(cmdstring,con);
cmd.ExecuteNonQuery();
con.Close();

I want to update date column which is stored in access database. But it gives me syntax error(missing operator) in query expression '03.03.2016 00:00:00' In access date column type is Date/Time.

Upvotes: 0

Views: 2067

Answers (2)

Beldi Anouar
Beldi Anouar

Reputation: 2180

Try with :

string cmdstring = "UPDATE table SET date='" + DateTime.Parse(datetxt.Text).ToString("dd/MM/yyy") +"' WHERE id ="+id;

Upvotes: 1

raBinn
raBinn

Reputation: 182

Apparently it seems a problem in the date format . The solution indicated by Beldi Anouar should funcionarte .

Good luck

Upvotes: 0

Related Questions