web 2.0

ASP.NET(vb.net) & ADO.NET and Excel (Odbc)

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

ASP.NET(vb.net) & ADO.NET and Excel (Odbc)

ASP.NET(vb.net) & ADO.NET and Excel (Odbc)

.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

One Response to “ASP.NET(vb.net) & ADO.NET and Excel (Odbc)”

  1. 1dramatist…

Leave a Reply

You must be logged in to post a comment.