MySqlCommand.ExecuteNonQuery 失败
我试图在 mysql 数据库中执行 INSERT 查询,但除了代码执行停止并且没有插入任何内容之外,什么也没有发生。 这是代码(连接是在另一点建立的并且正在工作):
query = string.Format("INSERT INTO users (username, settings) VALUES('{0}', '{1}')", userName, sw.ToString());
myCommand = new MySqlCommand();
myCommand.CommandText = query;
myCommand.Connection = con;
myCommand.ExecuteNonQuery();
如果我单步执行代码,它会在executenonquery之后停止,所以显然那里出了问题。天哪,我讨厌它不会向我抛出错误:(
I am trying to execute an INSERT query in a mysql DB, but it doesn't happen anything except that the code executions stops and nothing gets inserted.
Here is the code (the connection is made at another point and is working):
query = string.Format("INSERT INTO users (username, settings) VALUES('{0}', '{1}')", userName, sw.ToString());
myCommand = new MySqlCommand();
myCommand.CommandText = query;
myCommand.Connection = con;
myCommand.ExecuteNonQuery();
If I step the code, it stops after executenonquery, so obvisously something is wrong there. God I hate that it doesn't throw an error at me :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否检查过连接实际上已打开,并尝试通过将结果分配给 try catch 块中的 int 来执行该方法。
Have you checked the connection is actually open and tried executing the method by assigning the result to an int in a try catch block.