Link to home
Start Free TrialLog in
Avatar of Wanting2LearnMan
Wanting2LearnManFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Problem with oleDB Command Text

Whats wrong with this?

OleDbCommand cmd = mycon.CreateCommand();
            sMatchID = "test";
            sTime = "0001";
            sEvent = "TB";
            sPlayerNo = "11";
            sPlayerName = "Harry";
 cmd.CommandText = "insert into MatchStats values(" + sMatchID + ",'" + sTime + ",'" + sEvent + ",'" + sPlayerNo + ",'" + sPlayerName + "');";

I have an access database with a table called MatchStats with the above columns.

WHen the debugger comes to this line:
int temp = cmd.ExecuteNonQuery();
 I get an exception saying:
OleDBException was unhandled
Syntax error (missing operator) in query expression '0001',TB'.

Whats wrong?
SOLUTION
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial