connect = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" & "data source=" & BookToWorkOn & ";Extended Properties=Excel 8.0;")
connect.Open()
' Puts the ingredient column from Named Range [Ingredient} in
adapter = New System.Data.OleDb.OleDbDataAdapter("select * From [Ingredient]", connect)
adapter.Fill(dataset)
Me.DataGridView1.DataSource = dataset.Tables(0)
connect.Close()
'Adds the column data from the Named Range [Found] in
adapter = New System.Data.OleDb.OleDbDataAdapter("select * from [Found]", connect)
adapter.Fill(dataset)
Me.DataGridView2.DataSource = dataset.Tables(0)
connect.Close()
dataset.Clear()
In the above code I am trying to import two excel named ranges (columns) into a datagridview control so that they display in two columns. when I execute the code the first the colmn names are displayed properly and the first range row data displays properly in the first column but the row data in the second column displays in rows below the used rows in the first column. I need the row data from each column to be displayed side by side

New Topic/Question
Reply




MultiQuote


|