0

控制流 - SSIS

以下代码块位于 SSIS 包中的脚本任务(执行转储)中。该脚本被递归调用以获取数据库中的表列表:

Function ImportSQLServerToAccess(ByVal sMDBFile As String, ByVal sSource As String, ByVal sDestination As String, ByVal sServer As String, ByVal sDatabase As String) As Boolean
    Dim AccessConn As System.Data.OleDb.OleDbConnection
    If System.Environment.OSVersion.Version.Major >= 6 Then
        AccessConn = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sMDBFile + "")
    Else
        AccessConn = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sMDBFile + "")
    End If

    AccessConn.Open()

    Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO " + sDestination + "  FROM [" + sSource + "] IN '' [ODBC;Driver={SQL Server};Server=" + sServer + ";Database=" + sDatabase + ";Trusted_Connection=yes];", AccessConn)

    AccessCommand.ExecuteNonQuery()
    AccessCommand.Dispose()
    AccessConn.Close()
End Function

第一次调用执行转储脚本任务时,查询执行良好并将数据转储到 mdb,但此后每隔一次都会失败,异常'ODBC--连接到'{SQL Server}DEV01'失败'。我不确定为什么连接第二次失败但第一次成功。有什么建议的解决方法吗?

在此处输入图像描述

4

0 回答 0