Tuesday, June 28, 2005

Excel to Datagrid Migration in ASP.Net

This code migrates all excel data to datagrid in asp.net using vb language

Dim DS As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As System.Data.OleDb.OleDbConnection
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Wordlist.xls; " & _
"Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"select * from [Sheet1$]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)
MyConnection.Close()
DataGrid2.DataSource = DS
DataGrid2.DataBind()


Comments Please

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home