Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: Re: Help with connections in here Access only


Message #1 by "José Cassio Wendhausen" <jcassio@c...> on Tue, 15 Jan 2002 15:31:32
Hi Sunil Kumar.

I did what you said. Just altered variables to fit with my MDB. I have 

Access 97, NT 4.0 sp 6.



When I run this code, I got the following error:



Microsoft OLE DB Provider for ODBC Drivers error '80004005' 



[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database 

engine cannot open the file '(unknown)'. It is already opened exclusively 

by another user, or you need permission to view its data. 



But:

- The MDB isn´t openned by other user;

- Isn´t password protect;

- The IUSR_XXXX account has Full control in the right folder;

- The problem occurs from local or remote attempt connections;



Any idea about what can be wrong ?



Here, the your code modified:



> -------------------------------------------------

> -------------------------------------------------

> Start Code

> -------------------------------------------------

> -------------------------------------------------

> 

<html>

<body>

 

<%

@ LANGUAGE="VBSCRIPT"

ENABLESESSIONSTATE = "FALSE"

%>

<%



' To test if we have made a successful connection before including this 

' file we use this test. Leave ENABLETEST = "YES" uncommented until

' we have confirmation that we have the right connection variables

' Get confirmation by executing the page in your browser

' Once you get confirmation comment out ENABLETEST = "YES" so that

' ENABLETEST = "NO"

ENABLETEST = "YES"

'ENABLETEST = "No"



'If you are using a database that is passwordprotected comment out

'PASSWORD = "NO" and vice versa

Dim PASSWORD

'PASSWORD = "YES"

PASSWORD = "NO"





'If you are using a database that is password protectted

'Enter the username and password here

'Dont worry about commenting it out, the script does it for you

'if you are using a non password protected db

Dim CONNUSERNAME,CONNPASSWORD

CONNUSERNAME = "Admin"

CONNPASSWORD = "addbook"





' Enter the path to your database below

Dim DATAPATH

DATAPATH = "d:\inetpub\wwwroot\spp\Sppdados.mdb"



DIM ACCESSNEW,ACCESSOLD

'Here is an important part, are you using access2000 or access97

'ACCEESNEW = Access 2000 and ACCESSOLD = Access 97

'If you are using access 2000 comment out the access 97 string

'which is ACCESSOLD and vice versa

'ACCESSNEW = "TRUE"

ACCESSOLD = "TRUE"





'You dont need to edit anything else unless you want to chage the

'variables for your connection

'In that case, read instruction 5 at the end of this code





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

' Decide what DBCONN is going to be so we can select

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

If ACCESSNEW = "TRUE" AND PASSWORD = "YES" Then

DBCONN = "ONE"

End If



If ACCESSNEW = "TRUE" AND PASSWORD = "NO" Then

DBCONN = "TWO"

End IF



If ACCESSOLD = "TRUE" AND PASSWORD = "YES" Then

DBCONN = "THREE"

End If



If ACCESSOLD = "TRUE" AND PASSWORD = "NO" Then

DBCONN = "FOUR"

End If







Sub CONNECTION



Select Case DBCONN

	Case "ONE"

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

		Set ADDBOOK = Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "DRIVER={Microsoft Access Driver 

(*.mdb)};DBQ=" & DATAPATH & ";UID=" & CONNUSERNAME & ";PWD=" & CONNPASSWORD



	Case "TWO"

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

		Set ADDBOOK = Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data 

Source=" & DATAPATH & ";"



	Case "THREE"

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

		Set ADDBOOK = Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "DBQ=" & DATAPATH &  ";Driver={Microsoft 

Access Driver (*.mdb)};UID=" & CONNUSERNAME & ";PASSWORD=" & CONNPASSWORD



	CASE "FOUR"

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

		Set ADDBOOK = Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "DRIVER={Microsoft Access Driver 

(*.mdb)};DBQ=" & DATAPATH

	End Select

End Sub



%>

<%

' Testing part

If ENABLETEST = "YES" Then

CALL CONNECTION

Response.Write "If you you do not see any errors and only this message, 

the connection has worked. "

Response.Write "If you get errors make sure you only have 1 database 

uncommented and have the "

Response.Write "Variable PASSWORD uncommented once also. Make sure you 

have the right db type , "

Response.Write "Access 2000( Accessnew) or Access 97( Accessold). Make 

sure you have the right "

Response.Write "path to your db( DATAPATH) and MAKE SURE you have the 

PASSWORD variable commented "

Response.Write "accordingly to whether or not your db is password 

protected"

Response.Write "<br>Your dbconn type in this script was " & DBCONN

End If

%>

</body>

</html>

> 

Message #2 by Eli Schilling <eschilli@t...> on Tue, 15 Jan 2002 11:35:54 -0500
When declaring the path to your database you might try the MapPath 

function.



This:

' Enter the path to your database below

Dim DATAPATH

DATAPATH =3D "d:\inetpub\wwwroot\spp\Sppdados.mdb"



Should be this:



Dim DATAPATH

DATAPATH =3D Server.MapPath("Sppdados.mdb")



Regards,

Eli



-----Original Message-----

From: Jos=E9 Cassio Wendhausen [mailto:jcassio@c...]

Sent: Tuesday, January 15, 2002 7:32 AM

To: ASP Database Setup

Subject: [asp_database_setup] Re: Help with connections in here Access

only





Hi Sunil Kumar.

I did what you said. Just altered variables to fit with my MDB. I have

Access 97, NT 4.0 sp 6.



When I run this code, I got the following error:



Microsoft OLE DB Provider for ODBC Drivers error '80004005'



[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database

engine cannot open the file '(unknown)'. It is already opened 

exclusively

by another user, or you need permission to view its data.



But:

- The MDB isn=B4t openned by other user;

- Isn=B4t password protect;

- The IUSR_XXXX account has Full control in the right folder;

- The problem occurs from local or remote attempt connections;



Any idea about what can be wrong ?



Here, the your code modified:



> -------------------------------------------------

> -------------------------------------------------

> Start Code

> -------------------------------------------------

> -------------------------------------------------

>

<html>

<body>



<%

@ LANGUAGE=3D"VBSCRIPT"

ENABLESESSIONSTATE =3D "FALSE"

%>

<%



' To test if we have made a successful connection before including this 



' file we use this test. Leave ENABLETEST =3D "YES" uncommented until

' we have confirmation that we have the right connection variables

' Get confirmation by executing the page in your browser

' Once you get confirmation comment out ENABLETEST =3D "YES" so that

' ENABLETEST =3D "NO"

ENABLETEST =3D "YES"

'ENABLETEST =3D "No"



'If you are using a database that is passwordprotected comment out

'PASSWORD =3D "NO" and vice versa

Dim PASSWORD

'PASSWORD =3D "YES"

PASSWORD =3D "NO"





'If you are using a database that is password protectted

'Enter the username and password here

'Dont worry about commenting it out, the script does it for you

'if you are using a non password protected db

Dim CONNUSERNAME,CONNPASSWORD

CONNUSERNAME =3D "Admin"

CONNPASSWORD =3D "addbook"





' Enter the path to your database below

Dim DATAPATH

DATAPATH =3D "d:\inetpub\wwwroot\spp\Sppdados.mdb"



DIM ACCESSNEW,ACCESSOLD

'Here is an important part, are you using access2000 or access97

'ACCEESNEW =3D Access 2000 and ACCESSOLD =3D Access 97

'If you are using access 2000 comment out the access 97 string

'which is ACCESSOLD and vice versa

'ACCESSNEW =3D "TRUE"

ACCESSOLD =3D "TRUE"





'You dont need to edit anything else unless you want to chage the

'variables for your connection

'In that case, read instruction 5 at the end of this code





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

' Decide what DBCONN is going to be so we can select

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

If ACCESSNEW =3D "TRUE" AND PASSWORD =3D "YES" Then

DBCONN =3D "ONE"

End If



If ACCESSNEW =3D "TRUE" AND PASSWORD =3D "NO" Then

DBCONN =3D "TWO"

End IF



If ACCESSOLD =3D "TRUE" AND PASSWORD =3D "YES" Then

DBCONN =3D "THREE"

End If



If ACCESSOLD =3D "TRUE" AND PASSWORD =3D "NO" Then

DBCONN =3D "FOUR"

End If







Sub CONNECTION



Select Case DBCONN

	Case "ONE"

		Set ADDBOOKR =3D Server.CreateObject("ADODB.Recordset")

		Set ADDBOOK =3D Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "DRIVER=3D{Microsoft Access Driver

(*.mdb)};DBQ=3D" & DATAPATH & ";UID=3D" & CONNUSERNAME & ";PWD=3D" & 

CONNPASSWORD



	Case "TWO"

		Set ADDBOOKR =3D Server.CreateObject("ADODB.Recordset")

		Set ADDBOOK =3D Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "Provider=3DMicrosoft.Jet.OLEDB.4.0; Data

Source=3D" & DATAPATH & ";"



	Case "THREE"

		Set ADDBOOKR =3D Server.CreateObject("ADODB.Recordset")

		Set ADDBOOK =3D Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "DBQ=3D" & DATAPATH &  ";Driver=3D{Microsoft

Access Driver (*.mdb)};UID=3D" & CONNUSERNAME & ";PASSWORD=3D" & 

CONNPASSWORD



	CASE "FOUR"

		Set ADDBOOKR =3D Server.CreateObject("ADODB.Recordset")

		Set ADDBOOK =3D Server.CreateObject("ADODB.Connection")

		ADDBOOK.Open "DRIVER=3D{Microsoft Access Driver

(*.mdb)};DBQ=3D" & DATAPATH

	End Select

End Sub



%>

<%

' Testing part

If ENABLETEST =3D "YES" Then

CALL CONNECTION

Response.Write "If you you do not see any errors and only this message, 



the connection has worked. "

Response.Write "If you get errors make sure you only have 1 database

uncommented and have the "

Response.Write "Variable PASSWORD uncommented once also. Make sure you

have the right db type , "

Response.Write "Access 2000( Accessnew) or Access 97( Accessold). Make

sure you have the right "

Response.Write "path to your db( DATAPATH) and MAKE SURE you have the

PASSWORD variable commented "

Response.Write "accordingly to whether or not your db is password

protected"

Response.Write "<br>Your dbconn type in this script was " & DBCONN

End If

%>

</body>

</html>

>





eschilli@t...


$subst('Email.Unsub')






$subst('Email.Unsub').

Message #3 by "José Cassio Wendhausen" <jcassio@c...> on Tue, 15 Jan 2002 19:50:00
Thanks Eli.

I made this change, but not solves the problem.

I made other changes:



- IIS was setting both: anonymous access and Challenge/Response.



----------------------------------------------------------------------

> When declaring the path to your database you might try the MapPath 

> function.

> 

> This:

> ' Enter the path to your database below

> Dim DATAPATH

> DATAPATH =3D "d:\inetpub\wwwroot\spp\Sppdados.mdb"

> 

> Should be this:

> 

> Dim DATAPATH

> DATAPATH =3D Server.MapPath("Sppdados.mdb")

> 

> Regards,

> Eli

> 

Message #4 by "José Cassio Wendhausen" <jcassio@c...> on Tue, 15 Jan 2002 20:06:44
Thanks Eli.

I made this change, but not solves the problem.

I made other changes:



- IIS was setting both: anonymous access and Challenge/Response.

  Now: ONLY Challenge Response



- In the Case stucture:

  CASE "FOUR"

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

	Set ADDBOOK = Server.CreateObject("ADODB.Connection")

	***** ADDBOOK.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" 

& DATAPATH

	set rsSPP = ADDBOOK.execute("select sigla from OperSPP")



  I changed the line assigned with ***** by this:

  ADDBOOK.Open "DBQ=" & DATAPATH & ";" & "Driver={Microsoft Access Driver 

(*.mdb)};" & "DriverId=25;" & "FIL=MS Access;"



Whats happen now ?



- The server (local):

  Loads the page in the first time, but refresh only works after 1 or 2 

minutes.

  In the times when connection fails, I got this error: "Provider 

error '80004005' Unspecified error - line, 94"

  This line: Set ADDBOOKR = Server.CreateObject("ADODB.Recordset")



- From a PC network - Don´t works always. When the page fails to load, I 

got this error: 

"Microsoft OLE DB Provider for ODBC Drivers error '80004005' 



[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database 

engine cannot open the file '(unknown)'. It is already opened exclusively 

by another user, or you need permission to view its data. 



/spp/Alt1SiglasSpp.asp, line 94 "



THE SAME LINE !!!



I´m going crazy with this. Any suggestions ??





----------------------------------------------------------------------

> When declaring the path to your database you might try the MapPath 

> function.

> 

> This:

> ' Enter the path to your database below

> Dim DATAPATH

> DATAPATH =3D "d:\inetpub\wwwroot\spp\Sppdados.mdb"

> 

> Should be this:

> 

> Dim DATAPATH

> DATAPATH =3D Server.MapPath("Sppdados.mdb")

> 

> Regards,

> Eli

> 

Message #5 by "José Cassio Wendhausen" <jcassio@c...> on Wed, 16 Jan 2002 19:06:29
Hi friends.

I think that I need to tell it to you.

I changed the server where the files was hosted, and.... Got that dammit 

error again !! Therefore, I discovered that, due to network security 

implementation, somethings were changed in those servers...

I decided install a new server, just for test. After do this, put those 

ASP codes there and made a test...

All problems gone !! The pages works fine now. Problem solved.



This code has successfully opened the Database (Access 97):



Datapath= Server.MapPath("Sppdados.mdb")

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

Set ADDBOOK = Server.CreateObject("ADODB.Connection")

ADDBOOK.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & DATAPATH



Thanks for help !



__________________________________________________________________



> Thanks Eli.

> I made this change, but not solves the problem.

> I made other changes:

> 

> - IIS was setting both: anonymous access and Challenge/Response.

>   Now: ONLY Challenge Response

> 

> - In the Case stucture:

>   CASE "FOUR"

> 	Set ADDBOOKR = Server.CreateObject("ADODB.Recordset")

> 	Set ADDBOOK = Server.CreateObject("ADODB.Connection")

> 	***** ADDBOOK.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" 

> & DATAPATH

> 	set rsSPP = ADDBOOK.execute("select sigla from OperSPP")

> 

>   I changed the line assigned with ***** by this:

>   ADDBOOK.Open "DBQ=" & DATAPATH & ";" & "Driver={Microsoft Access 

Driver 

> (*.mdb)};" & "DriverId=25;" & "FIL=MS Access;"

> 

> Whats happen now ?

> 

> - The server (local):

>   Loads the page in the first time, but refresh only works after 1 or 2 

> minutes.

>   In the times when connection fails, I got this error: "Provider 

> error '80004005' Unspecified error - line, 94"

>   This line: Set ADDBOOKR = Server.CreateObject("ADODB.Recordset")

> 

> - From a PC network - Don´t works always. When the page fails to load, I 

> got this error: 

> "Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

> 

> [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database 

> engine cannot open the file '(unknown)'. It is already opened 

exclusively 

> by another user, or you need permission to view its data. 

> 

> /spp/Alt1SiglasSpp.asp, line 94 "

> 

> THE SAME LINE !!!

> 

> I´m going crazy with this. Any suggestions ??

> 

> 

> ----------------------------------------------------------------------


  Return to Index