Murray Brown
asked on
VB.net SQL Client version of OledB code to get data from Excel to SQL
Sub Excel_to_SQL()
' Create Data Table for MS-Office 2007 or 2003
Dim dtExcel As New System.Data.DataTable()
dtExcel.TableName = "MyExcelData"
Hi
What would the VB.net equivalent of the following code be?
Thanks
Dim SourceConstr As String = "Provider=Microsoft.ACE.OL EDB.12.0;D ata Source='C:\Users\Sachindra \Desktop\M yExcel2003 .xls';Exte nded Properties= 'Excel 8.0;HDR=Yes;IMEX=1'"
Dim con As New OleDbConnection(SourceCons tr)
Dim query As String = "Select * from [Sheet1$]"
Dim data As New OleDbDataAdapter(query, con)
data.Fill(dtExcel)
MsgBox("Data Imported Successfully into DataTable")
End Sub
' Create Data Table for MS-Office 2007 or 2003
Dim dtExcel As New System.Data.DataTable()
dtExcel.TableName = "MyExcelData"
Hi
What would the VB.net equivalent of the following code be?
Thanks
Dim SourceConstr As String = "Provider=Microsoft.ACE.OL
Dim con As New OleDbConnection(SourceCons
Dim query As String = "Select * from [Sheet1$]"
Dim data As New OleDbDataAdapter(query, con)
data.Fill(dtExcel)
MsgBox("Data Imported Successfully into DataTable")
End Sub
You mean VBA? The above code uses ADO.NET which is not available in VBA. You would need to use recordsets.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks