在我的代码中不断弹出错误(连接已打开) [英] an error keeping popping up in my codes (connection already open)
本文介绍了在我的代码中不断弹出错误(连接已打开)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个错误一直弹出!!!MySql.Data.dll 中发生类型为System.InvalidOperationException"的未处理异常
This error keeps popping up!!! An unhandled exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll
附加信息:连接已打开.
Additional information: The connection is already open.
Dim cmd As MySqlCommand
con.Open()
Try
cmd = con.CreateCommand()
cmd.CommandText = "update animal_sale set @NOAB,@Amount,@Tax,@Total where Species=@Species"
cmd.Parameters.AddWithValue("@Species", TextBoxSpecies.Text)
cmd.Parameters.AddWithValue("@NOAB", TextBoxNo.Text)
cmd.Parameters.AddWithValue("@Amount", TextBoxAmount.Text)
cmd.Parameters.AddWithValue("@Tax", TextBoxTax.Text)
cmd.Parameters.AddWithValue("@Total", TextBoxTotal.Text)
cmd.ExecuteNonQuery()
load()
Catch ex As Exception
End Try
End Sub
推荐答案
看起来您在执行查询后没有关闭连接.你只有
It looks like you are not closing the connection after executing the query. You only have
con.Open()
并且在
cmd.ExecuteNonQuery()
这篇关于在我的代码中不断弹出错误(连接已打开)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文