ASP.NET(vb.net) & ADO.NET and Excel (Odbc) - This article example scripts you will learn how to useĀ ADO.NET and Excel (Odbc) using ASP.NET Scripts.
ShotDev Focus:
- ASP.NET(vb.net) & ADO.NET and Excel (Odbc)
Example
AspNetAdoExcelOdbc.aspx
<%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.Odbc"%> <%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) Dim objConn As New OdbcConnection Dim dtAdapter As OdbcDataAdapter Dim dt As New DataTable Dim strConnString As String strConnString = "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO; " & _ "Excel 8.0; DBQ="&Server.MapPath("MyXls/MyExcelDB.xls")&"" objConn = New OdbcConnection(strConnString) objConn.Open() Dim strSQL As String strSQL = "SELECT * FROM [Sheet1$]" dtAdapter = New OdbcDataAdapter(strSQL, objConn) dtAdapter.Fill(dt) '*** BindData To GridView ***' Me.myGridView.DataSource = dt Me.myGridView.DataBind() dtAdapter = Nothing objConn.Close() objConn = Nothing End Sub </script> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form id="form1" runat="server"> <asp:GridView id="myGridView" runat="server"></asp:GridView> </form> </body> </html>
Screenshot
1dramatist…
…