C#查询mysql错误

linye523 2012-05-15 08:51:48
下面是什么错误。
代码如下
MySQLCommand comm = new MySQLCommand("select count(*) from maivpn where name=" + txtname.Text + " and p=" + txtpwd.Text, conn);
try
{
conn.Open();
if (Convert.ToInt32(comm.ExecuteScalar()) <= 0)
{
comm.CommandText = "insert into maivpn values(" + txtname.Text + "," + txtpwd.Text + "," + "true)";
if (comm.ExecuteNonQuery() > 0)
{
MessageBox.Show("注册成功");
}
}
else
{
MessageBox.Show("注册失败,此账号可能已存在");
}
}
catch (Exception ee)
{
txtname.Text = ee.Message;
MessageBox.Show(ee.Message);
}
finally {
conn.Close();
}

有时候报MySQLDriverCS Exception: MySQLDriverCS Error: wrong query.Unknown column 'qwe' in 'where clause'
有时候下面的

MySQLDriverCS Exception: MySQLDriverCS Error: wrong query.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 'w' at line 1
...全文
258 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
w767687781 2012-05-16
  • 打赏
  • 举报
回复
好像就是说SQL语句错误了吧 …………
  • 打赏
  • 举报
回复
SQL文的Where里没有‘qwe’,再检查一下你的代码?
theillusion 2012-05-15
  • 打赏
  • 举报
回复
sql语句有问题
linye523 2012-05-15
  • 打赏
  • 举报
回复
查询的错误,貌似

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧