我收到此错误:
Unknown column 'admin' in 'where clause'
Run Code Online (Sandbox Code Playgroud)
这是我的登录按钮的代码:
mycon.Open();
string cmdstr = "SELECT * FROM usersettingsdb WHERE user_ID = " + textBox1.Text + "";
cmd = new MySqlCommand(cmdstr, mycon);
dr = cmd.ExecuteReader();
string inputpw = "";
string dbpw = "";
while (dr.Read())
{
inputpw = maskedTextBox1.Text;
dbpw = (dr["user_pw"].ToString());
}
dr.Close();
mycon.Close();
Run Code Online (Sandbox Code Playgroud)
由于我的Select语句与我在网上看到的所有其他select语句相同,因此我无法理解为什么我会收到该错误
将文本框值括在单引号中
string cmdstr = "SELECT * FROM usersettingsdb WHERE user_ID = '" + textBox1.Text + "'";
Run Code Online (Sandbox Code Playgroud)
由Tigran评论.使用参数化查询而不是仅连接控件中的值
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |