问题描述
直到现在我只使用了没有这种问题的 Mssql Server,但现在我遇到了 MysqL Server 的问题。 我现在知道,MysqL 不支持 MARS(“多个活动结果集”),所以当我调用“Dataadapter.Update”时,我的多线程 VB.NET 服务出错。
Module GlobalVariables
Public eda As MysqLDataAdapter
Public dda As MysqLDataAdapter
Public dst As New ex___Service.ds
End Module
Public Sub Connect2Database(ByRef constr As String)
'MysqL
Dim con As New MysqLConnection(constr)
con.open()
eda = New MysqLDataAdapter("SELECT * FROM tbl1",con)
dda = New MysqLDataAdapter("SELECT * FROM tbl2",con)
Dim cb As MysqLCommandBuilder
cb = New MysqLCommandBuilder(TryCast(eda,MysqLDataAdapter))
eda.InsertCommand = cb.GetInsertCommand
eda.DeleteCommand = cb.GetDeleteCommand
eda.UpdateCommand = cb.GetUpdateCommand
cb = New MysqLCommandBuilder(TryCast(dda,MysqLDataAdapter))
dda.InsertCommand = cb.GetInsertCommand
dda.DeleteCommand = cb.GetDeleteCommand
dda.UpdateCommand = cb.GetUpdateCommand
con.Close()
GetData()
End Sub
Public Sub GetData()
eda.Fill(dst.tbl1)
dda.Fill(dst.tbl1)
End Sub
后来我在多线程环境中调用了一些:
eda.Update(dst.tbl1)
并得到异常:
已经有一个与此命令关联的打开的 DataReader 必须先关闭
是否有选项可以检查是否另一个线程使用更新写入数据库?或者检查连接是否打开?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)