<%@ 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 DataGrid ***'
Me.myDataGrid.DataSource = dt
Me.myDataGrid.DataBind()
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Excel Odbc</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DataGrid id="myDataGrid" runat="server"></asp:DataGrid>
</form>
</body>
</html>