0

Hi, I have an access databse, but the data is link to excel, so i cant changes the data inside access database. However, i just want to retrieve the data inside the access database using VB datagridview, but the system pop out an error said 'cannot find the input table or query'
Is it because the data is link with excel, so access databse cannot direct take the data?
Below is my code:\

Dim myconnectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb"
myconnection = New OleDbConnection(myconnectionstring)
myconnection.Open()

query = ("SELECT Device,Package FROM [Sheet1$]")
mycommand = New OleDbCommand(query, myconnection)
dr = mycommand.ExecuteReader
While dr.Read

DataGridView1.Rows.Add()
DataGridView1.Rows(n).Cells("Column1").Value = dr("Device")
DataGridView1.Rows(n).Cells("Column2").Value = dr("Package")


End While
dr.Close()
myconnection.Close()

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by G_Waddell
0

Hi,

Why use the Access DB? you can link directly to the Excel document as if it was a database table.

Try looking at the Data Files section of http://www.connectionstrings.com for the excel version you are using.

Also you can google ADO.net and Excel or VB.Net and Excel and get loads of examples.

Edited by G_Waddell: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.