Wanting2LearnMan
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.