|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cannot open Access database in ASP
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 xg wrote:
Show quote > Hi, I am writing an ASP page which contains the following code: You have an extra semicolon after the closing parenthesis, after your> > 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 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) -- Mike Brind permissions probably
http://www.powerasp.com/content/new/windows_2003_server_and_permissions.asp http://www.powerasp.com/content/new/windows_xp_pro_and_permissions.asp Show quote "Mike Brind" <paxton***@hotmail.com> wrote in message news:1142801566.903545.143410@e56g2000cwe.googlegroups.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;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) > > -- > Mike Brind > xg wrote:
Show quote > Hi, I am writing an ASP page which contains the following code: This is most likely a permissions problem. If your website is using > > 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. > 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" 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 Show quote "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message news:eYGu6O6SGHA.4300@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;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 > > -- > 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" > > 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: Show quote > 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 > > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message > news:eYGu6O6SGHA.4300@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;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 >> >> -- >> 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" 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 ------------------------------------------------------------------------ |
|||||||||||||||||||||||