且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#Winform,从oledb迁移到mysql代码后的问题

更新时间:2023-09-14 10:45:40

附近使用你需要删除SQL语句中的括号

You need to remove the brackets in the SQL statement
string sql = "SELECT COUNT(*) FROM account WHERE Access_Control = @code"

;



如果你需要在MySQL中使用一个关键字,你将它包装成两个``

就像

;

If you need use a keyword in MySQL you wrap it in two ` `
like

`Table`



(不知道这个角色叫什么)



[更新]

只是为了它的乐趣,测试一下


(Don't know what this character is called, though)

[UPDATE]
Just for the fun of it, test this

com.Parameters.Add("@code", SqlDbType.VarChar);
com.Parameters["@code"].Value = metroaccesscontroltxtBox.Text;



而不是


instead of

com.Parameters.AddWithValue("@code", metroaccesscontroltxtBox.Text);