Runtime error when trying to connect to an Access DB

J

Jim

Hello everyone,

This is my first time posting to a Usenet group, so please excuse any
Netiquette errors I may have in my post. I have used ASP.NET before
using C#, but never VB, so I'm trying to practice using VB. I have a
very simple page that I would like to connect to an Access DB and
output some fields. Here's the code that I have:

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<%
Dim strconn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" + Server.MapPath("~/test.mdb") & ";"
Dim sql As String = "SELECT * FROM Employees"
Dim connection As New OleDbConnection(strconn)
Dim ds As DataSet = New DataSet()
Dim da As New OleDbDataAdapter(sql, connection)
da.Fill(ds, "T1")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
%>

<html>

<head>
<title>test</title>
</head>

<body>

<%
Dim dc As DataColumn
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
For Each dc In ds.Tables(0).Columns
Response.Write(dr(dc.ColumnName).ToString())
Next
Next
%>

</body>
</html>


When I go to this page in my web browser, I get 'Server Error in '/
DotNet' Application, followed by 'Runtime Error'. The Description
says 'An application error occurred on the server.' There is more to
the error, but I'm assuming this is a generic error that you guys (and
gals) have seen before. Any suggestions?
 
S

sloan

Make sure you set permissions on the file AND the folder.

the folder: because it needs to create an .ldb file.

...

Other than that, you need to specify an exact message.

Turn off "friendly http errors" on your IE options. (something like that)

Remember "who are you" in a web environment. asp.net doesnt run under
IUSR_, it runs under ASPNET
 
J

Jim

Thanks for the reply. I have a feeling that it has something to do
with the folder permissions. I do have write access to this
directory, but maybe connecting to a DB is under a different setting?
I'm not really savvy with server permissions, but I'll check into it.
Thanks again.

Oh, I'm doing this at work, so that's why I need to check into it. I
just realized that I probably sounded a little strange saying I needed
to check into it if it was on my own computer.
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top