Click to See Complete Forum and Search --> : MS Access + ASP Pages


rgupta1963
12-13-2004, 04:18 AM
Hi there...newbie here...

I'm using MS Access on my website to control access to various pages...this all seems to work fine if I have the following directory structure...

/usrmgmt -----> contains all the asp pages which controll access to the site...

Now any pages I have the at are one level down from the root...i.e

/home/home.asp......No problems with making a connection to the MS Access database

But as soon as I move it one directory further down....the problems start...i.e

/home/2004/user.asp

The error I get is: -

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process

As soon as I move the page back up one level - the problem goes away......

Anyhelp would be most appreaciated........ :rolleyes: :rolleyes:

buntine
12-13-2004, 05:42 AM
This error is normally caused by one of two things.

1) The directory in which the database resides does not have the correct permissions. The MDB file needs to be able to create a temporary file when you access it.

2) The DSN (or physical file path) provided points to an incorrect location. Make sure the file is in the correct place.

Im guessing the latter is your problem.

Regards.

rgupta1963
12-13-2004, 06:48 AM
Hi there....I've checked the "phyical" paths and they all seem to be correct....

It seems I only get this error if the page they access the MS Access database is more than 1 level down from the root....

:( :( :(

I use an include statement at the top of the page
which points it to the area where the relevant files exist.

<!--#include file="../usrmgmt/common.asp"--> (works fine)

and I change this depending on how many levels I go down.......


<!--#include file="../../usrmgmt/common.asp"--> (doesn't work)

buntine
12-13-2004, 07:38 AM
Oh OK. You may need to use virtual instead of file for SSI's when you go more than one level down from the root. I didnt realise you were using includes.

<!--#include virtual="../../usrmgmt/common.asp"-->

- Virtual refers to a path beginning with a virtual directory.
- File refers to a relative path.

I hope this solves your problem.

Regards.

rgupta1963
12-13-2004, 07:44 AM
many thanks.......will give it a try this evening:D :D :D

russell
12-13-2004, 01:33 PM
this<!--#include virtual="../../usrmgmt/common.asp"-->
should actually be<!--#include virtual="/usrmgmt/common.asp"-->The path should be relative to the root.

rgupta1963
12-13-2004, 01:44 PM
Hi there....unfortunately this doesn't seem to work either..
I get the following error

The include file '../../../../usrmgmt/common.asp' was not found.
/pgs/financials/2005/addfees.asp, line 2


I tried the virtual includes on pages that work....but they also give me the same above error once the make the change from: -

<!--#include file="../usrmgmt/common.asp"-->

to

<!--#include virtual="../usrmgmt/common.asp"-->

Thanks for helping me out with this....it's most appreaciated

russell
12-13-2004, 02:02 PM
don't slash-dot your way to it. start with a leading slash and put the path relative to the root. this way will work from anywhere in your site.

<!--#include virtual="/usrmgmt/common.asp"-->

rgupta1963
12-14-2004, 03:00 AM
Many thanks - I will give it a try this evening:p :p

rgupta1963
12-14-2004, 04:10 AM
Hi there....ok I've made the change as outlined but it now gives me the same error as before.....

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x7e8 Thread 0xce8 DBC 0x23954ec Jet'.

/usrmgmt/common.asp, line 57

:( :( :( :( :( :(

russell
12-14-2004, 04:17 AM
did you check the permissions as Buntine suggested?

how are you connecting to the db?

need to see your code to tell whats wrong.

check your odbc data sources applet in the control panel, and see if MS Access driver is in the default list.

rgupta1963
12-14-2004, 04:27 AM
Hi russell

Many thanks for ur help on this....i really do appreaciate this

I've checked the permissions and all taht seems to be fine...The connection to the Access database works fine if it is accessed by a page one level down from the root....and further levels below that and I get the message above....the code is the include file is pasted below: -


<!--#include file="strings.asp" --><%

'Dimension variables
Dim adoCon 'Database Connection Variable
Dim strCon 'Holds the Database driver and the path and name of the database
Dim strSQL 'Database query sring
Dim strSQL1
Dim strSQL2
Dim strSQL3
Dim strSQL4
Dim strSQL5
Dim strSQL6
Dim strSQL7
Dim stravrSQL1
Dim strtotSQL1
Dim strSQLev1
Dim strSQLev2
Dim strSQLev3
Dim strSQLev4
Dim strSQLev5
Dim strSQLev6
Dim strSQLev7
Dim strUserGood
Dim strUserID
Dim strUserAccess
Dim strFullName
Dim strEmail
Dim strUsername
Dim strUserLastVist
Dim strUsercode
Dim rsMemberCheck

strUsername = "Visitor"

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'------------- If you are having problems with the script then try using a diffrent driver or DSN by editing the lines below --------------

'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath(strConString)

'Database driver info for Brinkster
'strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath("/USERNAME/db/users.mdb") 'This one is for Brinkster users place your Brinster username where you see USERNAME

'Alternative drivers faster than the basic one above
'strCon = "Provider=Microsoft.Jet.OLEDB.3.51;uid=;pwd=; Data Source=" & Server.MapPath("users.mdb") 'This one is if you convert the database to Access 97

'strCon = "Provider=Microsoft.Jet.OLEDB.4.0;uid=;pwd=; Data Source=" & Server.MapPath("users.mdb") 'This one is for Access 2000/2002

'If you wish to use DSN then comment out the driver above and uncomment the line below (DSN is slower than the above drivers)
'strCon = "DSN = " & strConTring 'Place the DSN where you see DSN_NAME

'---------------------------------------------------------------------------------------------------------------------------------------------

'Set an active connection to the Connection object
adoCon.Open strCon

strUserGood = Session("UserGood")
strUsercode = Session("Usercode")

If strUserGood = "" Then strUserGood = Request.Cookies("Login")("UserGood")
if strUsercode = "" Then strUsercode = Request.Cookies("Login")("Usercode")

If strUserGood = "True" and NOT strUsercode = "" then

Set rsMemberCheck = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tblUsers.* FROM tblUsers WHERE tblUsers.User_code = '" & strUsercode & "'"

rsMemberCheck.Open strSQL, strCon

If rsMemberCheck.EOF Then
Response.Cookies("Login")("UserGood") = ""
Response.Cookies("Login")("Usercode") = ""
End If
If NOT rsMemberCheck.EOF Then
strUserID = rsMemberCheck("ID")
strUsername = rsMemberCheck("Username")
strUserLastVist = rsMemberCheck("LastVist")
strUserAccess = rsMemberCheck("Access")
strFullName = rsMemberCheck("FullName")
strEMail = rsMemberCheck("Email")
End If

set rsMemberCheck = Nothing
End If
%>
and the "strings.asp" file contains the following: -

<%

'----------
'---- Please Note that True = 'Yes' and False = 'No'
'----------

'Dataname and location. Default = asp_database_login_v1_8_1.mdb
'------------------------------------------------------------
Const strConString = "../_private/asp_db.mdb" 'Default Database String

'Email functions
'------------------------------------------------------------
Const strMailComponent = "CDONTS" 'The mail compent for the email feature. The supported mail componts are: CDONTS , Jmail , AspEmail
Const strIncomingMailServer = "mail.me2uweb.co.uk" 'Incoming mail address for the server. Ex: mail.yoursite.com
Const strEmailOnRegister = "True" 'Sends an email to the admin when a new user registers NOTE: Only supports CDONTS (set to Yes if you want to allow it) Default = False
Const strEmailOnRegisterTitle = "The New User on your site is: " 'The title of the email sent for new users.
Const strFromEmailAddress = "webmaster@porchestergs.com" 'This is the email address people will see when the get their lost password
Const strAllowLostPassword = "False" 'Allow lost password feature? NOTE: Only supports CDONTS (set to Yes if you want to allow it). (to turn on make it 'True') Default = False
Const strEmailSubject = "Lost Password" 'This is the Subject of the lost password

'Admin and user functions
'------------------------------------------------------------
Const strLevel2Delete = "False" 'Allow level 2 members to delete other members?
Const strLevel2Admin = "False" 'Allow level 2 members add/modify other members. NOTE, level 2 cannot delete members, or see there passwords. Default = True
Const strLevel1Edit = "True" 'Allow level 1 members to modify their profile. NOTE, level 1 cannot change there login count, access levels, or anyother members. Default = True
Const strAllowRegister = "False" 'Allow people to register? Change to to "No" if you dont want to allow registering. Default = True
Const strAllowLogin = "False" 'Allow Login After Register? Change to to "False" if you dont want to allow login in after registering. Default = True
Const strAllowDoubleUserNames = "False" 'Allow more than 1 users names to be the same? Change to "False" if you to allow double usernames. Default = False
Const strAllowDoubleEmails = "False" 'Allow more then one unique email address to be the same? Change to "False" if you dont want to allow double emails for users. Default = False
Const strRequireEmail = "True" 'Make the email address of each user required
Const strLevel1Login = "../home/home.asp" 'Where the access level 1 (lowest member) is redirected to after login
Const strLevel2Login = "admin_menu.asp" 'Where the access level 2 is redirected to after login
Const strLevel3Login = "admin_menu.asp" 'Where the access level 3 (admin) is redirected to after login


'Login pages
'------------------------------------------------------------
Const strLoginPage = "login.asp" 'Default Page for logging in. Default = login.asp
Const strAuthorizedPage = "../home/home.asp" 'Authorized Page for after logging in. Default = authorised_user_page.asp
Const strUnAuthorisedPage = "login.asp" 'Unauthorised Page for unauthorized users. Default = unauthorised_user_page.htm
%>

russell
12-15-2004, 12:20 AM
this is the problem:

Const strConString = "../_private/asp_db.mdb" 'Default Database String


Same thing. Don't slash-dot your way to it. make it a path relative to the root. Also, lets combine that line and the following one (we'll take away the const too) --

strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath(strConString)


Dim strConString
strConString = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath("/private/asp_db.mdb")

That work for ya?

russell
12-15-2004, 12:25 AM
one more thing. change this:

<!--#include file="strings.asp" -->

to

<!--#include virtual="/strings.asp"-->

including any sub-directories from the root. For example

<!--#include virtual="/includes/strings.asp"-->

It is a good practice to get out of the habit of using include file, and start include virtual for all of your includes. This gives you much greater flexibility, and avoids problems like you are now experiencing.

:)