Hrvoje

Hrvoje

  • NA
  • 47
  • 0

excel update

Sep 2 2008 7:53 AM

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);

}


Answers (2)