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()

Recommended Answers

All 2 Replies

Who can help me??? please... urgent!!!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.