我正在尝试使用以下命令更新数据:
string updateQuery = "UPDATE gebruikers SET Naam='" + txtNaam.Text
+ "', Voornaam='" + txtVoornaam.Text
+ "', Geboortedatum='" + txtGeboortedatum.Text
+ "', Email='" + txtEmail.Text
+ "', Gebruikernaam='" + txtGebruikersnaam.Text
+ "', Wachtwoord='" + txtWachtwoord.Text
+ "', Straat='" + txtStraat.Text
+ "', Huisbus='" + txtHuisbus.Text
+ "', Postcode='" + txtPostcode.Text
+ "', Plaats='" + txtPlaats.Text
+ "', Telenummer='" + txtTelefoonnummer.Text
+" WHERE Gebr_id = " + int.Parse(txtID.Text);
executeMyQuery(updateQuery);
但是我得到了这个错误:
您的SQL语法中有一个错误;请查看与您的MariaDB服务器版本对应的手册,了解要在第1行的"test WHERE Gebr_id =1“附近使用的正确语法。
有人知道我怎么解决这个问题吗?
发布于 2018-05-28 17:04:48
where部分之前漏掉了一个引号(')。试试这个:
string updateQuery = "UPDATE gebruikers SET Naam='" + txtNaam.Text +
"', Voornaam='" + txtVoornaam.Text + "', Geboortedatum='" +
txtGeboortedatum.Text + "', Email='" + txtEmail.Text +
"', Gebruikernaam='" + txtGebruikersnaam.Text + "', Wachtwoord='" +
txtWachtwoord.Text + "', Straat='" + txtStraat.Text +
"', Huisbus='" + txtHuisbus.Text + "', Postcode='" + txtPostcode.Text +
"', Plaats='" + txtPlaats.Text + "', Telenummer='" +
txtTelefoonnummer.Text + "' WHERE Gebr_id = " + int.Parse(txtID.Text);
executeMyQuery(updateQuery);
https://stackoverflow.com/questions/50562664
复制相似问题