Hay people
I’m very green to the world of VB.Net 2005 so would appreciate some help.
I would like to know how would I import a Excel spread sheet into a Datagrid?
This is what I have so far, but for some reason I get no errors and no data? But nothing happens.
[FONT="]Dim[/FONT][FONT="] DS As System.Data.DataSet[/FONT]
[FONT="] Dim MyCommand As System.Data.OleDb.OleDbDataAdapter[/FONT]
[FONT="] Dim MyConnection As System.Data.OleDb.OleDbConnection[/FONT]
[FONT="] [/FONT]
[FONT="] MyConnection = New System.Data.OleDb.OleDbConnection( _[/FONT]
[FONT="] "provider=Microsoft.Jet.OLEDB.4.0; " & _[/FONT]
[FONT="] "data source=D:\Stock.XLS; " & _[/FONT]
[FONT="] "Extended Properties=Excel 8.0;")[/FONT]
[FONT="] ' Select the data from Sheet1 of the workbook.[/FONT]
[FONT="] MyCommand = New System.Data.OleDb.OleDbDataAdapter( _[/FONT]
[FONT="] "select * from [Sheet1$]", MyConnection)[/FONT]
[FONT="] [/FONT]
[FONT="] DS = New System.Data.DataSet()[/FONT]
[FONT="] MyCommand.Fill(DS)[/FONT]
[FONT="] MyConnection.Close()[/FONT]
[FONT="] [/FONT]
[FONT="]Thanks[/FONT]
[FONT="] [/FONT]
[FONT="]Decklan[/FONT]
I’m very green to the world of VB.Net 2005 so would appreciate some help.
I would like to know how would I import a Excel spread sheet into a Datagrid?
This is what I have so far, but for some reason I get no errors and no data? But nothing happens.
[FONT="]Dim[/FONT][FONT="] DS As System.Data.DataSet[/FONT]
[FONT="] Dim MyCommand As System.Data.OleDb.OleDbDataAdapter[/FONT]
[FONT="] Dim MyConnection As System.Data.OleDb.OleDbConnection[/FONT]
[FONT="] [/FONT]
[FONT="] MyConnection = New System.Data.OleDb.OleDbConnection( _[/FONT]
[FONT="] "provider=Microsoft.Jet.OLEDB.4.0; " & _[/FONT]
[FONT="] "data source=D:\Stock.XLS; " & _[/FONT]
[FONT="] "Extended Properties=Excel 8.0;")[/FONT]
[FONT="] ' Select the data from Sheet1 of the workbook.[/FONT]
[FONT="] MyCommand = New System.Data.OleDb.OleDbDataAdapter( _[/FONT]
[FONT="] "select * from [Sheet1$]", MyConnection)[/FONT]
[FONT="] [/FONT]
[FONT="] DS = New System.Data.DataSet()[/FONT]
[FONT="] MyCommand.Fill(DS)[/FONT]
[FONT="] MyConnection.Close()[/FONT]
[FONT="] [/FONT]
[FONT="]Thanks[/FONT]
[FONT="] [/FONT]
[FONT="]Decklan[/FONT]