J
JamesB
I am trying to insert a row to an Access database:
INSERT INTO tblTest (Val1, Val2, Val3, Val4, Val5) VALUES ('blah', 0, '',
'', 'foo');
If I run this in my code:
String insStr = "INSERT INTO INSERT INTO tblTest (Val1, Val2, Val3, Val4,
Val5) VALUES ('blah', 0, '', '', 'foo');
OleDbCommand insCmd = new OleDbCommand(insStr, DBConn);
try
{
insCmd.ExecuteScalar();
}
I get an error "Syntax error in INSERT statement". Yet if I create a new
query in the Access db and paste the insert statement in there, it works
fine! All fields are text apart from Val2, which is a Yes/No field.
Anyone spot what I'm doing wrong here?
INSERT INTO tblTest (Val1, Val2, Val3, Val4, Val5) VALUES ('blah', 0, '',
'', 'foo');
If I run this in my code:
String insStr = "INSERT INTO INSERT INTO tblTest (Val1, Val2, Val3, Val4,
Val5) VALUES ('blah', 0, '', '', 'foo');
OleDbCommand insCmd = new OleDbCommand(insStr, DBConn);
try
{
insCmd.ExecuteScalar();
}
I get an error "Syntax error in INSERT statement". Yet if I create a new
query in the Access db and paste the insert statement in there, it works
fine! All fields are text apart from Val2, which is a Yes/No field.
Anyone spot what I'm doing wrong here?