I have an excel sheet with 2 tables both wit 6 columns an each starts at columnB
Table1 with headers starts at B16:G16 AND ENDS AT B62:G62.
Table2 with headers starts at B91:G91 AND ENDS AT B118:G118.
I want to load table1 to Datagridview1 and table2 to Datagridview2
Please help

    Dim MyConnection As System.Data.OleDb.OleDbConnection
    Dim DtSet As System.Data.DataSet
    Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
    MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\korisnik\Desktop\" & File.Text & "';Extended Properties=Excel 8.0;")
    MyCommand = New System.Data.OleDb.OleDbDataAdapter("select Sifra , Amount from [Ispis$]", MyConnection)
    MyCommand.TableMappings.Add("Table", "Net-informations.com")
    DtSet = New System.Data.DataSet
    DataGridView1.DataSource = DtSet.Tables(0)
3 Years
Discussion Span
Last Post by Shark_1

Remember, to get ans. you will have to describe your probs. and the exception what are you facing. No one here to do the ans. finding qus./excp. from your post.
Please make your post more distinct.

From my opinion, 1) an exception can occur from the contruction of your connection string(no single quotation is needed).
2) Nowhere you tried to open the connection object.

Edited by Shark_1

Votes + Comments
Nice answer.
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.