Hello all,
I am a newbie in .net world and i am trying to populate MS Access through excel using Visual Basic.
I have created the code to take the input of excel but i don't have any idea how to go ahead. Supposing my excel has only 1 sheet with huge amount of data, and i want to upgrade my Access database everyday using excel sheet then how to do it?
Here is what i have done so far:
'opening Excel Sheet to import
Dim xlopenfile As OpenFileDialog = New OpenFileDialog()
Dim xlpath As String
xlopenfile.Title = "Select Excel Sheet"
xlopenfile.Filter = "Excel 2000 to 2003 (*.xls)|*.xls| Excel 2007 (*.xlsx)|*xlsx"
xlopenfile.InitialDirectory = "C:\"
xlopenfile.ShowDialog()
xlpath = xlopenfile.FileName()
If xlpath <> "" Then
'database connection with the path specified above
Dim xlsconn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=xlpath; Properties=""Excel 8.0;HDR=Yes;IMEX=1""")
'Fetching table of Excel in to dataadapter
Dim xlda As New OleDbDataAdapter("select * from [sheet1$]", xlsconn)
End If
I know i have to write more statements in If statement, the next step is to create the access database here and then to populate the excel sheet in access table, anyone can give me an example here? it will be very helpful if you mark the comments and describe the code a bit, understanding something is far more important then to just copy paste it. Please also tell me how to get the UPDATING BAR during the access update process !!
Thanks
I am a newbie in .net world and i am trying to populate MS Access through excel using Visual Basic.
I have created the code to take the input of excel but i don't have any idea how to go ahead. Supposing my excel has only 1 sheet with huge amount of data, and i want to upgrade my Access database everyday using excel sheet then how to do it?
Here is what i have done so far:
'opening Excel Sheet to import
Dim xlopenfile As OpenFileDialog = New OpenFileDialog()
Dim xlpath As String
xlopenfile.Title = "Select Excel Sheet"
xlopenfile.Filter = "Excel 2000 to 2003 (*.xls)|*.xls| Excel 2007 (*.xlsx)|*xlsx"
xlopenfile.InitialDirectory = "C:\"
xlopenfile.ShowDialog()
xlpath = xlopenfile.FileName()
If xlpath <> "" Then
'database connection with the path specified above
Dim xlsconn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=xlpath; Properties=""Excel 8.0;HDR=Yes;IMEX=1""")
'Fetching table of Excel in to dataadapter
Dim xlda As New OleDbDataAdapter("select * from [sheet1$]", xlsconn)
End If
I know i have to write more statements in If statement, the next step is to create the access database here and then to populate the excel sheet in access table, anyone can give me an example here? it will be very helpful if you mark the comments and describe the code a bit, understanding something is far more important then to just copy paste it. Please also tell me how to get the UPDATING BAR during the access update process !!
Thanks