Damon

Damon

  • NA
  • 6
  • 0

Insert Into error(solved)

Mar 5 2008 11:52 AM
 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;

}