0
嘿傢伙我差不多完成了我的數據庫項目的CRUD項目。我只是想完成並完成刪除功能。刪除查詢異常被稱爲C#
query = string.Format("DELETE FROM customers WHERE `cid`= {0};", mDeleteTextBox);
我的變量mDeleteTextBox填充了我想要的值。 我的查詢出了什麼問題?
錯誤信息
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.TextBox, Text: 6' at line 1
的可能的複製[如何逃避作爲列名的保留字? MySQL/Create Table](http://stackoverflow.com/questions/2889871/how-do-i-escape-reserved-words-used-as-column-names-mysql-create-table) – Eris
另外,你的'{ 0}'需要引號,或者更好的是使用參數化查詢:http://stackoverflow.com/questions/652978/parameterized-query-for-mysql-with-c-sharp – Eris
另外,檢查在mDeleteTextBox類型是字符串。也許你想寫mDeleteTextBox.Text? Nigrimmist – Nigrimmist