我尝试使用sql批量复制将数据从excel表复制到sql server,但是
每当尝试打开excel表数据库的连接时我都会收到错误我的意思是微软的ace oledb连接。
我试过"启用32位应用=真"在应用程序池然后它工作正常,但我不想将其设置为true。 我怎么解决它?
我在此 excel_con.Open() 中共享示例代码,此时出现错误 '上传并保存文件 Dim excelPath As String = Server.MapPath("〜/ Files /")+ Path.GetFileName(FileUpload1.PostedFile.FileName) FileUpload1.SaveAs(excelPath)
Dim connString As String = String.Empty
Dim extension As String = Path.GetExtension(FileUpload1.PostedFile.FileName)
Select Case extension
Case ".xls"
'Excel 97-03
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & excelPath & ";Extended Properties=""Excel 8.0;HDR=YES;IMEX=1"""
Exit Select
Case ".xlsx"
'Excel 07 or higher
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & excelPath & ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""
Exit Select
End Select
Using excel_con As New OleDbConnection(connString)
excel_con.Open()
Dim sheet1 As String = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing).Rows(0)("TABLE_NAME").ToString()
Dim dtExcelData As New DataTable()