I'm using this code to update row in excel worksheet, but I get an error: "Syntax error in update statement";
code:
DataSet ds = new DataSet(); OleDbConnection oledbConn = new OleDbConnection(sConn); try{
oledbConn.Open();
OleDbCommand cmd = new OleDbCommand("UPDATE [Members$] SET Name = '" + txtName.Text + "'," + "Email='" + txtEmail.Text + "'," + "Address = '" + txtAddress.Text + "'," + "City='" + txtCity.Text + "'," + "State='" + ddState.SelectedValue + "'," + "Password= '" + txtPassword.Text + "' WHERE ID = 51", oledbConn); OleDbDataReader reader = cmd.ExecuteReader();reader.Close();
oledbConn.Close();
}
catch (OleDbException oex){
error =
new Exception(oex.Message + oex.StackTrace);}
HrvojePosted Sep 2, 2008, 9:22 AM
REsult:
"UPDATE [PopisClanova$] SET Name = 'Hrvoje Voda',Email='[email protected]',Address = 'F. Dursta 12',City='Zagreb',State='ARUBA',Password= 'hswebs08' WHERE ID = 51"
Raj MishraPosted Sep 2, 2008, 9:06 AM
Before executing cmd.ExecuteReader(); Can you see the result of cmd.CommandText in debugger or immidiate window ?
And check some where you are missing “,” or “’” ?