How to get data from Excel sheet, and add that data into Ms-access database?

N

Nagarajan .A

I need to read an excel file, and add that data into msaccess database.
Can anyone help me?

Thanks in advance.
 
P

Paul Clement

¤ I need to read an excel file, and add that data into msaccess database.
¤ Can anyone help me?
¤

Try the following:

Public Sub ImportExcelToAccess()

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

AccessConn.Open()

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

AccessCommand.ExecuteNonQuery()
AccessConn.Close()


End Sub


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top