We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim connString As String = ConfigurationManager.ConnectionStrings("xls").ConnectionString ' Create the connection object Dim oledbConn As OleDbConnection = New OleDbConnection(connString) Try ' Open connection oledbConn.Open() ' Create OleDbCommand object and select data from worksheet Sheet1 Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn) ' Create new OleDbDataAdapter Dim oleda As OleDbDataAdapter = New OleDbDataAdapter() oleda.SelectCommand = cmd ' Create a DataSet which will hold the data extracted from the worksheet. Dim ds As DataSet = New DataSet() ' Fill the DataSet from the data extracted from the worksheet. oleda.Fill(ds, "Employees") ' Bind the data to the GridView GridView1.DataSource = ds.Tables(0).DefaultView GridView1.DataBind() Catch Finally ' Close connection oledbConn.Close() End Try End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.