Hi everyone
I cannot display my access table. I can only see the heading display not
the data. The path of the database file is correct. Please check if I
have made an error in <asp:datagrid/> or in the connection string. But
this codes work in Brinkster hosting. It does not display in localhost
when I clicked "View in browser" after "save all" and "build solution"
and "build project". Please help.
<%@ Page Language="vb" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="vb" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim DBConn as OleDbConnection
Dim DBCommand as OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection("PROVIDER=" _
& "Microsoft.Jet.OLEDB.4.0; " _
& "DATA SOURCE=" _
& Server.MapPath
("/AccessTest1/db/Northwind.MDB;" ) )
DBCommand = New OleDbDataAdapter ("select
EmployeeID, FirstName, LastName from Employees", DBConn)
DBCommand.Fill(DSPageData, "Employees")
MyDataGrid.DataSource=DSPageData.Tables
("Employees").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<h2>
Use An Access Data Base
</h2>
<ASP:DataGrid id="MyDataGrid" Runat="server" Width="700"
BackColor="#ccccff" BorderColor="black" ShowFooter="False" CellPadding="3"
CellSpacing="0" Font-Name="Arial" Font-Size="8pt" HeaderStyle-
BackColor="#aaaadd" EnableViewState="False" />
</form>
</body>
</HTML>
Plyng
14 March 2003