0
Reply

Insert Into error(solved)

Damon

Damon

Mar 5 2008 11:52 AM
2k
 have run into a problem with my instert satement that gives me a syntax error whenever i try and add an extra value to it.

 

This one works but

string sqlString1 = "INSERT INTO QuoteHeader (QuoteHeaderID, CustomerID, EmployeeID) VALUES("

+ newOrderHeader

+ ",'" + custID

+ "','" + empID

+ "')";

 

add another value and I get a synax error And i'm not sure why.

string sqlString1 = "INSERT INTO QuoteHeader (QuoteHeaderID, CustomerID, EmployeeID, Month) VALUES("

+ newOrderHeader

+ ",'" + custID

+ "','" + empID

+ "','" + textBox6.Text

+ "')";

 

Code Snippet

try

{

cmd = new OleDbCommand(sqlString1, connectCmd);

int rowsReturned = cmd.ExecuteNonQuery();

}

catch (Exception ex)  [error message given here is syntax error in INSERT INTO statement]

{

string s = ex.Message;

DisposeResources(ref oleDbDataAdapter, ref ds, ref connectFill, ref connectCmd, ref cmd);

return;

}