Misae
Misae
CC#
Created by Misae on 2/8/2023 in #help
✅ ASP.NET OLEDB ExecuteNonQuery UpdateSyntax Error
I made this
OleDbCommand sqlcommand2 = new OleDbCommand();
string update = "UPDATE [TBL-Users] SET username = '" + Change2UsernameTextBoxID.Text +"'"+ "," + " password = '" + Change2PasswordTextBoxID.Text + "' WHERE username = '" + ChangeUpdateUserNameTextBoxID.Text + "' AND password = '" + ChangeUpdatePasswordTextboxID.Text + "'";
sqlcommand2 = new OleDbCommand(update,connection);
sqlcommand2.ExecuteNonQuery();

connection.Close();
Response.Write("<script>alert('Update Successful');</script>");
OleDbCommand sqlcommand2 = new OleDbCommand();
string update = "UPDATE [TBL-Users] SET username = '" + Change2UsernameTextBoxID.Text +"'"+ "," + " password = '" + Change2PasswordTextBoxID.Text + "' WHERE username = '" + ChangeUpdateUserNameTextBoxID.Text + "' AND password = '" + ChangeUpdatePasswordTextboxID.Text + "'";
sqlcommand2 = new OleDbCommand(update,connection);
sqlcommand2.ExecuteNonQuery();

connection.Close();
Response.Write("<script>alert('Update Successful');</script>");
But it always says that I made a syntax error on my update, but when I use it on SQL query in Microsoft Access, it works just fine on the same table. I would get if it actually just doesn't work and I fucked up, but it works on Access so I'm super confused. Any help would be greatly appreciated
5 replies