Cannot open Access database in ASP

X

xg

Hi, I am writing an ASP page which contains the following code:

var MM_DBConn=Server.CreateObject("ADODB.Connection");
MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\trio.mdb;"); // failed on this line
//MM_editQuery is an INSERT sql statement
MM_DBConn.Execute(MM_editQuery);

When I run this on a Windows 2000 Professional system, I got the following
error:

Microsoft JET Database Engine error '80004005'

Not a valid file name.

And it points out that it failed on the MM_DBConn.Open statement.

However, if I copy the above code to a Visual Basic 6.0 form (on the same
machine) like this:

Private Sub Command1_Click()
Dim o As Object
Dim rs As Object

Set o = CreateObject("adodb.connection")
Call o.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\trio.mdb")
Set rs = o.execute("select count(*) from comments")

End Sub

Everything works. Can someone tell me what went wrong? Thanks!

xg
 
M

Mike Brind

xg said:
Hi, I am writing an ASP page which contains the following code:

var MM_DBConn=Server.CreateObject("ADODB.Connection");
MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\trio.mdb;"); // failed on this line
//MM_editQuery is an INSERT sql statement
MM_DBConn.Execute(MM_editQuery);

When I run this on a Windows 2000 Professional system, I got the following
error:

Microsoft JET Database Engine error '80004005'

Not a valid file name.

And it points out that it failed on the MM_DBConn.Open statement.

However, if I copy the above code to a Visual Basic 6.0 form (on the same
machine) like this:

Private Sub Command1_Click()
Dim o As Object
Dim rs As Object

Set o = CreateObject("adodb.connection")
Call o.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\trio.mdb")
Set rs = o.execute("select count(*) from comments")

End Sub

Everything works. Can someone tell me what went wrong? Thanks!

xg

You have an extra semicolon after the closing parenthesis, after your
connection string. It should look like this:

MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\trio.mdb;")

You'll also need to do the same on the following line:

MM_DBConn.Execute(MM_editQuery)
 
B

Bob Barrows [MVP]

xg said:
Hi, I am writing an ASP page which contains the following code:

var MM_DBConn=Server.CreateObject("ADODB.Connection");
MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\trio.mdb;"); // failed on this line
//MM_editQuery is an INSERT sql statement
MM_DBConn.Execute(MM_editQuery);

When I run this on a Windows 2000 Professional system, I got the
following error:

Microsoft JET Database Engine error '80004005'

Not a valid file name.

This is most likely a permissions problem. If your website is using
Anonymous access, then the IUSR_machinename account needs to be granted
Change permissions for the folder containing your database file (which
probably should be located in a subfolder, not in the root).
http://www.aspfaq.com/show.asp?id=2009
 
X

xg

Thanks everyone. I grant the "Modify" permission of
"c:\inetpub\wwwroot\triomotors\" for user "IUSR_DESKTOP" and the code now
looks like this:

var MM_DBConn=Server.CreateObject("ADODB.Connection");
MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\inetpub\wwwroot\triomotors\trio.mdb;");
MM_DBConn.Execute(MM_editQuery);

I still get the same error message. Please help. Thanks!

xg
 
B

Bob Barrows [MVP]

It's got nothing to do with your problem, but you really should put the
folder containing the database outside of the wwwroot folder for security
reasons.

A couple questions:
Where is this code located? If it's in one of the event handler subs in
global.asa, then the IWAM_machinename account also needs Modify permissions
for the folder containing the database.
Is this database file located on the same machine as the website?
Is your website using Anonymous access? If it's using Integrated
Authentication with Anonymous disabled, then all database users require
Modify permissions for the folder containing the database, not just IUSR and
IWAM.
Have you modified the isolation settings for your application? With some
settings, the IWAM account is doing the work, not the IUSR, so you need to
grant permissions to the IWAM account.
 

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,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top