Public Sub Main()
Dim connSource As New System.Data.Odbc.OdbcConnection
Dim cmdSource As New System.Data.Odbc.OdbcCommand
Dim cmdupdate As New System.Data.Odbc.OdbcCommand
Dim connsql As System.Data.Odbc.OdbcConnection
Dim cmdsql As System.Data.Odbc.OdbcCommand
connsql = New System.Data.Odbc.OdbcConnection
strsqlConnectionString = "Driver={ODBC Driver 11 for SQL Server};" & _
"Server=MyDatabaseServer;" & _
"DataBase=MyDatabase;" & _
"Trusted_Connection=Yes;"
connsql.ConnectionString = strsqlConnectionString
connsql.Open()
cmdSource.Connection = connSource
cmdupdate.Connection = connsql
cmdsql = New System.Data.Odbc.OdbcCommand
Dim m_strSourceExcelFileName As String
m_strSourceExcelFileName = Dts.Variables("User::FileName").Value.ToString()
Dim m_strSourceFilePath As String = "D:\Files\2017\"
m_strConnSource = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + m_strSourceFilePath + "\" + m_strSourceExcelFileName + "; Extended Properties='Excel 12.0 Xml;HDR=NO'"
connSource.ConnectionString = m_strConnSource
connSource.Open()
我在 SSIS 脚本任务中有上述代码片段。脚本任务包含将读取数据从 excel 复制到 SQL Server 2014 的代码。
我在'connSource.Open()'
上面代码段的最后一行收到以下错误。
错误 [IM002] [Microsoft][ODBC Driver Manager] 未找到数据源名称且未指定默认驱动程序
我似乎无法弄清楚我的连接字符串可能有什么问题。我在机器上安装了 AccessDatabaseEngine_x64.exe。