Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.
Protected Function ExcelConnection() As OleDbCommand ' Connect to the Excel Spreadsheet Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("/uploaded/ExcelImport.xls") & ";" & _ "Extended Properties=Excel 8.0;" ' create your excel connection object using the connection string Dim objXConn As New OleDbConnection(xConnStr) objXConn.Open() ' use a SQL Select command to retrieve the data from the Excel Spreadsheet ' the "table name" is the name of the worksheet within the spreadsheet ' in this case, the worksheet name is "Members" and is expressed as: [Members$] Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1$]", objXConn) Return objCommand End Function Protected Sub ButtonView_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonView.Click PanelUpload.Visible = False PanelView.Visible = True PanelImport.Visible = False ' Create a new Adapter Dim objDataAdapter As New OleDbDataAdapter() ' retrieve the Select command for the Spreadsheet objDataAdapter.SelectCommand = ExcelConnection() ' Create a DataSet Dim objDataSet As New DataSet() ' Populate the DataSet with the spreadsheet worksheet data objDataAdapter.Fill(objDataSet) ' Bind the data to the GridView GridViewExcel.DataSource = objDataSet.Tables(0).DefaultView GridViewExcel.DataBind() 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.