Microsoft.ace.oledb.12.0未在本地计算机上注册 [英] Microsoft.ace.oledb.12.0 not registered on the local machine
问题描述
,我不想将我的配置从86bit更改为某些原因
所以现在我应该怎么做
任何喜欢的解决方案
任何一个面对同一个解决方案像这样
我的代码是
Dim MyConnection As System.Data .OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim fBrowse As New OpenFileDialog
with fBrowse
.Filter =Excel文件(*。xlsx)| * .xlsx |所有文件(*。*)| *。*
.FilterIndex = 1
.Title =从Excel文件
结束
如果fBrowse.ShowDialog()= Windows.Forms.DialogResult.OK然后
Dim fname As String
fname = fBrowse.FileName
MyConnection = New System.Data.OleDb.OleDbConnection(Provider = Microsoft.ACE.OLEDB.12.0; Data Source ='& fname&'; &Extended Properties = Excel 8.0;)
MyCommand = New System.Data.OleDb.OleDbDataAdapter(select * from [Sheet1 $],MyConnection)
MyCommand.TableMappings.Add(表,CurrencyRate)
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
MyConnection.Close()
为DtSet中的每个Dr As DataRow。表(0).Rows
下一个
MsgBox(Successfully Saved)
如果
但在这段代码中,我收到错误
Microsoft.ace.oledb.12.0未注册在本地机器上
我之前解决了我的问题,但是我看到很多用户访问问题,所以我想我应该回答别人帮助
在我的问题我问:
- 我有64位操作系统
-
具有32位MS Office
所以为此我们不能确定什么是edb连接版本我们必须使用,所以我们有从Microsoft的替代库将ms办公产品集成到我们的应用程序。
Microsoft.Office.Interop
下载并安装此库按照此链接 Interop
,以下是我的代码示例以进一步帮助
Dim table As New DataTable(CurrencyRate)
Dim OFD As New OpenFileDialog
Dim strDestination As String
使用OFD
.Filter =Excel Office | * .xls; *。xlsx
.FileName =
如果.ShowDialog()<> Windows.Forms.DialogResult.OK然后
返回False
结束如果
strDestination = .FileName
结束
Dim xlApp As Microsoft.Office.Interop .Excel.Application
Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim xlRange As Microsoft.Office.Interop.Excel .Range
Dim xlCol As Integer
Dim xlRow As Integer
Dim Data(0 To 3)As String
带表
.Clear()
如果strDestination<> 然后
xlApp =新的Microsoft.Office.Interop.Excel.Application
xlWorkbook = xlApp.Workbooks.Open(strDestination)
xlWorkSheet = xlWorkbook.ActiveSheet()
xlRange = xlWorkSheet.UsedRange
如果xlRange.Columns.Count> 0然后
如果xlRange.Rows.Count> 0然后
对于xlRow = 2到xlRange.Rows.Count这里xlRow是从2 coz开始在exvel表中主要第一行是标题行
对于xlCol = 1到xlRange.Columns.Count
数据(xlCol - 1)= xlRange.Cells(xlRow,xlCol).text
下一个
.LoadDataRow(Data,True)
下一个
xlWorkbook.Close()
xlApp.Quit()
KillExcelProcess()
End If
End If
Else
MessageBox.Show(请选择Excel文件,信息,MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
结束如果
结束
i have a situation in which i have to inport the Excel sheet or file to my database using vb.net i know the code and the process for doing this but the issue is
- I have 64 bit operating system
- having 32 bit MS Office
and i don't want to change my Configuration from to 86bit due to some othere reason so now what should i do any prefer solution any one face same solution like this
my code is
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim fBrowse As New OpenFileDialog
With fBrowse
.Filter = "Excel files(*.xlsx)|*.xlsx|All files (*.*)|*.*"
.FilterIndex = 1
.Title = "Import data from Excel file"
End With
If fBrowse.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim fname As String
fname = fBrowse.FileName
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source='" & fname & " '; " & "Extended Properties=Excel 8.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
MyCommand.TableMappings.Add("Table", "CurrencyRate")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
MyConnection.Close()
For Each Dr As DataRow In DtSet.Tables(0).Rows
Next
MsgBox("Successfully Saved")
End If
but in this code i got error of
Microsoft.ace.oledb.12.0 not registered on the local machine
i solve my problem time ago but i saw many user visiting this Question so i think i should answer for others help in my question i ask that
- I have 64 bit operating system
having 32 bit MS Office so for this we can not sure that what oledb connection version we have to use so for this we have alternate library from Microsoft to integrate ms office products to our applications.
Microsoft.Office.Interop
to download and install this library follow this link Interop
and bellow is my code sample for further help
Dim table As New DataTable("CurrencyRate")
Dim OFD As New OpenFileDialog
Dim strDestination As String
With OFD
.Filter = "Excel Office|*.xls;*.xlsx"
.FileName = ""
If .ShowDialog() <> Windows.Forms.DialogResult.OK Then
Return False
End If
strDestination = .FileName
End With
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim xlRange As Microsoft.Office.Interop.Excel.Range
Dim xlCol As Integer
Dim xlRow As Integer
Dim Data(0 To 3) As String
With table
.Clear()
If strDestination <> "" Then
xlApp = New Microsoft.Office.Interop.Excel.Application
xlWorkbook = xlApp.Workbooks.Open(strDestination)
xlWorkSheet = xlWorkbook.ActiveSheet()
xlRange = xlWorkSheet.UsedRange
If xlRange.Columns.Count > 0 Then
If xlRange.Rows.Count > 0 Then
For xlRow = 2 To xlRange.Rows.Count 'here the xlRow is start from 2 coz in exvel sheet mostly 1st row is the header row
For xlCol = 1 To xlRange.Columns.Count
Data(xlCol - 1) = xlRange.Cells(xlRow, xlCol).text
Next
.LoadDataRow(Data, True)
Next
xlWorkbook.Close()
xlApp.Quit()
KillExcelProcess()
End If
End If
Else
MessageBox.Show("Please Select Excel File", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End With
by doing this you will have you excel data in your DataTable and then its on you where you want to save like save it in the sql server or storage area. let me know for further clarification.
这篇关于Microsoft.ace.oledb.12.0未在本地计算机上注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!