I'm trying to get my update command in SQL to work. Every time I try to update a record I get the following error unclosed quotation mark after the character string. Here my code:
String^ connectionString = L"**********";
SqlConnection^ myCon = gcnew SqlConnection(connectionString);
SqlCommand^ myCommand = gcnew SqlCommand("UPDATE ******* SET Customer_Name = '" + this -> txtName -> Text + "', Customer_Address = '" + this -> txtPhone -> Text + "', Customer_City = '" + this -> txtCity -> Text + "', Customer_State = '" + this -> txtState -> Text + "', Customer_Zip = '" + this -> txtZip -> Text + "', Customer_Phone = '" + this -> txtPhone -> Text + "', Customer_Email = '" + this -> txtEmail -> Text + "' where Customer_Name = '" + this -> txtName -> Text + ",);", myCon);
SqlDataReader^ myReader;
try {
myCon -> Open();
myReader = myCommand -> ExecuteReader();
MessageBox::Show("Updated!!");
}
catch (Exception^ ex) {
MessageBox::Show(ex->Message);
}
I am not sure how to fix this error. Any help would be great.
Customer_Name='
isn't closed. – Oncaphillis