连接正忙于其他命令的结果来源:SQL Server的Microsoft OLE DB提供程序 [英] connection is busy with results for other command Source: Microsoft OLE DB Provider for SQL Server

查看:124
本文介绍了连接正忙于其他命令的结果来源:SQL Server的Microsoft OLE DB提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

我在网络服务中使用以下代码填充SQL 2008数据库.

I use the following code in a webservice to fill a SQL 2008 database.

           strConnection ="Provider = SQLNCLI10;数据源=". & (getPath("database"))& "初始目录= cmdb_prod;用户ID = cmdb_prod;密码= cmdb_prod;"
           objConnection =新的OleDbConnection(strConnection)
           objConnection.Open()
           objAdapter =新的OleDbDataAdapter()
           objAdapter.ContinueUpdateOnError = True
          昏暗的cb作为新的OleDbCommandBuilder(objAdapter)
          对于Me.intI = 0到ds.Tables.Count-1
                            如果ds.Tables(intI).Rows.Count> 0然后
                    cb.RefreshSchema()
                    ListBox1.Items.Add(ds.Tables(intI).TableName)
                    objAdapter.SelectCommand = New OleDbCommand("SELECT * FROM [" + ds.Tables(intI).TableName +]",objConnection)
                    objAdapter.Fill(ds,ds.Tables(intI).TableName.ToString)
                    objAdapter.UpdateCommand = cb.GetUpdateCommand()
                    'AddHandler objAdapter.RowUpdating,新的OleDbRowUpdatingEventHandler(AddressOf OnRowUpdating)
                    AddHandler objAdapter.RowUpdated,新的OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
                    objAdapter.Update(ds,ds.Tables(intI).TableName.ToString)
                    RemoveHandler objAdapter.RowUpdating,新的OleDbRowUpdatingEventHandler(AddressOf OnRowUpdating)
                    RemoveHandler objAdapter.RowUpdated,新的OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
                    intK = intK +1
                            如果结束
          下一个
           objConnection.Close()

            strConnection = "Provider=SQLNCLI10;Data Source=" & (getPath("database")) & ";Initial Catalog= cmdb_prod;User ID=cmdb_prod;Password=cmdb_prod;"
            objConnection = New OleDbConnection(strConnection)
            objConnection.Open()
            objAdapter = New OleDbDataAdapter()
            objAdapter.ContinueUpdateOnError = True
            Dim cb As New OleDbCommandBuilder(objAdapter)
            For Me.intI = 0 To ds.Tables.Count - 1
                If ds.Tables(intI).Rows.Count > 0 Then
                    cb.RefreshSchema()
                    ListBox1.Items.Add(ds.Tables(intI).TableName)
                    objAdapter.SelectCommand = New OleDbCommand("SELECT * FROM [" + ds.Tables(intI).TableName + "] ", objConnection)
                    objAdapter.Fill(ds, ds.Tables(intI).TableName.ToString)
                    objAdapter.UpdateCommand = cb.GetUpdateCommand()
                    'AddHandler objAdapter.RowUpdating, New OleDbRowUpdatingEventHandler(AddressOf OnRowUpdating)
                    AddHandler objAdapter.RowUpdated, New OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
                    objAdapter.Update(ds, ds.Tables(intI).TableName.ToString)
                    RemoveHandler objAdapter.RowUpdating, New OleDbRowUpdatingEventHandler(AddressOf OnRowUpdating)
                    RemoveHandler objAdapter.RowUpdated, New OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
                    intK = intK + 1
                End If
            Next
            objConnection.Close()

 

Sub OnRowUpdating(ByVal发送者为对象,ByVal args为OleDbRowUpdatingEventArgs)
       'intialiseren交易错误计数器
      如果args.StatementType = StatementType.Insert然后
          对于Me.intJ = 0到args.Row.ItemArray.Length-1
                             transactionlogToFile(("Table:"& args.TableMapping.ToString&"[[Inserted]"& DateTime.Now&& args.Row(intJ)))
                             intL = intL + 1
          下一个
      如果结束
   结束

Sub OnRowUpdating(ByVal sender As Object, ByVal args As OleDbRowUpdatingEventArgs)
        'intialiseren transaction error counter
        If args.StatementType = StatementType.Insert Then
            For Me.intJ = 0 To args.Row.ItemArray.Length - 1
                transactionlogToFile(("Table: " & args.TableMapping.ToString & "[Inserted] " & DateTime.Now & " " & args.Row(intJ)))
                intL = intL + 1
            Next
        End If
    End Sub


    '
   私有子OnRowUpdated(按对象发送方为By,将发送方作为System.Data.OleDb.OleDbRowUpdatedEventArgs)
       'initialiseren交易成功计数器
      如果发生e.Status = UpdateStatus.Errors然后
           transactionlogToFile((错误消息:& e.Errors.Message.ToString()&",来源:& e.Errors.Source.ToString())& vbCrLf)
           e.Status = UpdateStatus.SkipCurrentRow
           intN = intN +1
      其他
           'transactionlogToFile(vbTab&"Updated"& vbCrLf)
           intM = intM +1
      如果结束
   结束


    '
    Private Sub OnRowUpdated(ByVal sender As Object, ByVal e As System.Data.OleDb.OleDbRowUpdatedEventArgs)
        'initialiseren tranaction succes counter
        If e.Status = UpdateStatus.ErrorsOccurred Then
            transactionlogToFile(("Error Message: " & e.Errors.Message.ToString() & ", Source: " & e.Errors.Source.ToString()) & vbCrLf)
            e.Status = UpdateStatus.SkipCurrentRow
            intN = intN + 1
        Else
            'transactionlogToFile(vbTab & "Updated" & vbCrLf)
            intM = intM + 1
        End If
    End Sub

当我使用事件处理程序objAdapter.RowUpdating时,出现了我的讨论标题中提到的错误.

When I use the eventhandler objAdapter.RowUpdating, I get the error like mentioned in the title of my discussion.

有人知道这是怎么发生的吗?

Anyone an idea how this happens?

亲切的问候,

于尔根

 

推荐答案

您好,于尔根,

Hi Jurgen,

您的意思是,当您使用事件处理程序objAdapter.RowUpdating时,会发生错误,但是当您不使用事件处理程序objAdapter.RowUpdating时,就不会发生错误?您是否有多个任务同时使用同一连接 ?您正在使用交易吗?

Do you mean that when you use the eventhandler objAdapter.RowUpdating, the error occurs but when you do not use the eventhandler objAdapter.RowUpdating, the error does not occur ? Do you have more than one task using the same connection at the same time ? Are you using transaction ?

最诚挚的问候,
亚历克斯·梁

Best regards,
Alex Liang


这篇关于连接正忙于其他命令的结果来源:SQL Server的Microsoft OLE DB提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆