ASPX database connection problem

A

Albert

********************
My code:
********************
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
sub Page_Load(Sender as Object, e as EventArgs)
'set up connection
dim objConn as new OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\ASPNET\data\banking.mdb")

'open connection
dim objCmd as OleDbDataAdapter = new
OleDbDataAdapter _
("select * from tblUsers", objConn)

'fill dataset
dim ds as DataSet = new DataSet()
objCmd.Fill(ds, "tblUsers")

'select data view and bind to server control
MyDataList.DataSource = ds.Tables("tblUsers"). _
DefaultView
MyDataList.DataBind()
end sub
</script>

<html><body>
<ASP:DataList id="MyDataList" RepeatColumns="2"
RepeatDirection="Vertical" runat="server">
<ItemTemplate>
<div style="padding:15,15,15,15;font-size:10pt;
font-family:Verdana">
<div style="font:12pt verdana;color:darkred">
<i><b><%# DataBinder.Eval
(Container.DataItem, "FirstName")%>&nbsp;
<%# DataBinder.Eval
(Container.DataItem, "LastName")%>
</i></b>
</div>
<br>
<b>Address: </b><%# DataBinder.Eval
(Container.DataItem, _
"Address") %><br>
<b>City: </b><%# DataBinder.Eval
(Container.DataItem, _
"City")%><br>
<b>State: </b><%# DataBinder.Eval _
(Container.DataItem, "State") %><br>
<b>ZIP: </b><%# DataBinder.Eval _
(Container.DataItem, "Zip") %><br>
<b>Phone: </b><%# DataBinder.Eval _
(Container.DataItem, "Phone") %><br>
</div>
</ItemTemplate>
</ASP:DataList>
</body></html>


****************************************
Here is the error message I received:
*******************************************
No error information available: 0x800401F9.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No
error information available: 0x800401F9.

Source Error:


Line 16: 'fill dataset
Line 17: dim ds as DataSet = new DataSet()
Line 18: objCmd.Fill(ds, "tblUsers")
Line 19:
Line 20: 'select data view and bind to server control


Source File: C:\Inetpub\wwwroot\AspNet\21Days\day08
\listing0801.aspx Line: 18

Stack Trace:


[OleDbException (0x800401f9): No error information
available: 0x800401F9.]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32
hr) +20
System.Data.OleDb.OleDbConnection.CreateProviderError
(Int32 hr) +23
System.Data.OleDb.OleDbConnection.CreateProvider
(OleDbConnectionString constr) +107
System.Data.OleDb.OleDbConnection.Open() +203
System.Data.Common.DbDataAdapter.QuietOpen
(IDbConnection connection, ConnectionState& originalState)
+44
System.Data.Common.DbDataAdapter.FillFromCommand(Object
data, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
+304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
String srcTable) +36
ASP.listing0801_aspx.Page_Load(Object Sender, EventArgs
e) in C:\Inetpub\wwwroot\AspNet\21Days\day08
\listing0801.aspx:18
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top