470,591 Members | 1,557 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Cannot open Access database in ASP

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;D ata
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


Mar 19 '06 #1
6 3732

xg wrote:
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;D ata
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;D ata
Source=c:\trio.mdb;")

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

MM_DBConn.Execute(MM_editQuery)

--
Mike Brind

Mar 19 '06 #2
xg wrote:
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;D ata
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

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 19 '06 #3
permissions probably

http://www.powerasp.com/content/new/...ermissions.asp

http://www.powerasp.com/content/new/...ermissions.asp
"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...

xg wrote:
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;D ata
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;D ata
Source=c:\trio.mdb;")

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

MM_DBConn.Execute(MM_editQuery)

--
Mike Brind

Mar 20 '06 #4
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;D ata
Source=c:\inetpub\wwwroot\triomotors\trio.mdb;");
MM_DBConn.Execute(MM_editQuery);

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

xg

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eY**************@TK2MSFTNGP14.phx.gbl...
xg wrote:
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;D ata
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

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Mar 20 '06 #5
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.

xg wrote:
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;D ata
Source=c:\inetpub\wwwroot\triomotors\trio.mdb;");
MM_DBConn.Execute(MM_editQuery);

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

xg

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eY**************@TK2MSFTNGP14.phx.gbl...
xg wrote:
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;D ata
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

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 20 '06 #6
pen

You can try this codes bellow. The Asp page must save under the
directory "c:\inetpub\wwwroot\triomotors\" .
Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
DBPath = "Data Source=" & Server.MapPath("trio.mdb")

Set MM_DBConn = Server.CreateObject("ADODB.Connection")
MM_DBConn.Open Provider & DBPath
MM_DBConn.Execute("MM_editQuery")

--
pen
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Mar 30 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by ultraton | last post: by
24 posts views Thread by dancer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.