Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
VB
    Public Sub ImportExcelToAccess()

        Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=c:\db1.mdb")

        AccessConn.Open()

        'New table
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [tblSheet1] FROM
[Excel 8.0;DATABASE=c:\Book1.xls;HDR=NO;IMEX=1].[Sheet1$]", AccessConn)

        AccessCommand.ExecuteNonQuery()
        AccessConn.Close()


    End Sub


What I have tried:

I am trying to import an Excel worksheet into an existing Access database table using vb.net/ado.net. The "select" statement works fine
for creating a new table, but I cannot get the correct syntax for an "INSERT" statement that will populate an existing
table.
Posted
Updated 12-Apr-16 7:09am

1 solution

I gave you the links to two CodeProject articles that would help you to do this in your original of this question at How can I import excel to ACCESS ?[^]. Please do not repost the same question, edit the original.
 
Share this answer
 
Comments
ionMEMBER 12-Apr-16 13:19pm    
Yes thanks but in this quesetion project when I click |Browse| and after |Retrieve|:
The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
What to do?
Richard MacCutchan 12-Apr-16 13:48pm    
Install the Jet driver.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900