首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >尝试更新sql数据库c#中的数据时出错

尝试更新sql数据库c#中的数据时出错
EN

Stack Overflow用户
提问于 2018-05-28 17:02:15
回答 1查看 54关注 0票数 -3

我正在尝试使用以下命令更新数据:

代码语言:javascript
复制
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“附近使用的正确语法。

有人知道我怎么解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-28 17:04:48

where部分之前漏掉了一个引号(')。试试这个:

代码语言:javascript
复制
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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50562664

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档