Question ADO Connection string Fun!

evilradish

Registered User.
Local time
Today, 04:17
Joined
Jun 11, 2010
Messages
15
I have been designing asp pages to connect to access databases to display information to users. This works fine on my local machine but when i point my adocon to network locations it does not work.

I am 90% sure its because the network path contains spaces but I have been unsuccessful in finding a way around this (changing the path is not an option)

Would anyone care to enlighten me? :D
 
As much as I like radishes (I'm the sod at the salad counter at the supermarket that steals them all out of the lettuce tray) you'll still have to provide a bit of detail as to what you've tried - and in what way it's failing. (Actual code and error messages).

Cheers.
 
you'll still have to provide a bit of detail as to what you've tried - and in what way it's failing. (Actual code and error messages).
What?! You've lost the ability to read minds Leigh? Oh now I AM disappointed. :D


smiletongueout.jpg
 
Ah t'was always just a trick. Mere slight of hand.
It's just that I've been found out now.
 
hahaha :)

Heres a chunck of the code I have included someof the connections I have tried and If they have worked. Hope this is clearer.
Code:
<html>
<head>
<title>My First ASP Page</title>
</head>
<body>
<body bgcolor="white" text="black">
Set adoCon = Server.CreateObject("ADODB.Connection")

'---------------Connections----------------------------------
'works
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\asptest\db1.mdb"

'does not work
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\ukaccounts\accounts\Revenue\SYSTEMS_FINANCE_DO_NOT_USE_OR_DELETE\DO_NOT_USE\Tonys Corner\Product Control Backend Aid\Product_Control_Automatic_Daily_Process_Aid_BACKEND.mdb

'works
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\ukaccounts\accounts\test.mdb

Set rsnew = Server.CreateObject("ADODB.Recordset")
 
Last edited by a moderator:
I wonder if escaping the path in same manners as is done in a cmd.exe would fix it?

Code:
Data Source=""\\ukaccounts\accounts\Revenue\SYSTEMS_FINAN CE_DO_NOT_USE_OR_DELETE\DO_NOT_USE\Tonys Corner\Product Control Backend Aid\Product_Control_Automatic_Daily_Process_Aid_BA CKEND.mdb""

Note: if this is the last parameter, make sure you close the entire string with one more quote mark:
Code:
...mdb"""
 
Not a reason in itself no. Spaces are fine... though that is one hella long UNC path.

What was the error message?
I presume it's not an entirely acccurate representation of the code?
For example does the path really end:

...Aid_BA CKEND.mdb

Including space and lack of closing quote? ;-)
 
For example does the path really end:

...Aid_BA CKEND.mdb

Forum issue there. I added the code tags which keeps that from happening so the original posted you should be able to see now up in the code window.
 
Not a reason in itself no. Spaces are fine... though that is one hella long UNC path.

Didn't think so but was having trouble recalling if escaping was needed in that context.

The other reason I can think of is lack of permissions, I suppose.

What was the error message?

This. Would be just slightly more efficient than trying to do long-distance telepathy, methinks. ;)
 
Morning! :cool: thanks everyone for your input so far.
I can confirm that the connection string was indeed my first issue

I can confirm that all local tests now work
Now back to that nasty long unc path :)

Woking
'adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='c:\asp test\Product_Control_Automatic_Daily_Process_Aid_BACKEND.mdb'"

Not working :(
'adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='\\ukaccounts\accounts\Revenue\SYSTEMS_FINANCE_DO_NOT_USE_OR_DELETE\DO_NOT_USE\Tonys Corner\Product Control Backend Aid\Product_Control_Automatic_Daily_Process_Aid_BACKEND.mdb'"

After adding the single speech marks as well The error has moved further down the page to this line

error: Error Type:
ADODB.Recordset (0x800A0E7D)
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
/Test/ASPTEST.asp, line 40


code: (line 40) rsnew.Open strSQL, adoCon
 
please ignore last post...

It was a typo...

my error is still

Error Type:
Microsoft JET Database Engine (0x80004005)
The Microsoft Jet database engine cannot open the file '\\ukaccounts\accounts\Revenue\SYSTEMS_FINANCE_DO_NOT_USE_OR_DELETE\DO_NOT_USE\Tonys Corner\Product Control Backend Aid\Product_Control_Automatic_Daily_Process_Aid_BACKEND.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
/Test/ASPTEST.asp, line 26

which is the connection string. Do i need to provide credentials even though the db is not password protected?

Im going to look at permissions as my asp page uses anon currently.
 
Last edited:
The error is still that? ;-)

So, do you have full read/write/create/delete/marry/copulate permission on the directory in question?
(You need to be able to create and delete a lock file to have non-exclusive permission and of course you need to edit same file and the MDB itself).

Cheers.
 
well I have permission from my domain account to that location but I did not consider that the server hosting the asp page would need permissions. So that is what I am looking into now :)

What can I say. Big learning curve ;)
 
Right...
I can confirm that I have permission to the network location in the connection string.

I created a htm page using the access page wizard to test the connection to the networked database and It worked fine. So I would have thought I am missing something in my connection string in the asp page above?

I had a look in the htm file that access output and the connection string is crazy long. Something in there is what I need maybe?


<a:ConnectionString>Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=I:\Tonys Corner\Product Control Backend Aid\Product_Control_Automatic_Daily_Process_Aid_BACKEND.mdb;Mode=Share Deny None;Extended Properties=&quot;&quot;;Persist Security Info=False;Jet OLEDB:System database=&quot;&quot;;Jet OLEDB:Registry Path=&quot;&quot;;Jet OLEDB:Database Password=&quot;&quot;;Jet OLEDB:Engine Type=0;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password=&quot;&quot;;Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False</a:ConnectionString>
 
Hi,

i have a pre made .asp page that connects to a sever database ( local to the asp page ) and it is set out as follows-


Code:
Function GetDatabaseLocation()
Dim strDatabasePath

	strDatabasePath = "data\unlock.mdb"

	GetDatabaseLocation =  Server.MapPath(strDatabasePath)

end function


Function GetConnectionString()

	GetConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="  & GetDatabaseLocation()

end function

Private Function GetRecord(strQueryString)

	'define SQL connection variables
	Dim strConnection
	Dim objConnection
	Dim objRecordSet

	'Define the database connection string
	strConnection = GetConnectionString()

	'Open the database
	Set objConnection = server.createobject("ADODB.Connection")
	objConnection.open strConnection
	Set objRecordSet = server.createobject("ADODB.Recordset")

	on error resume next
	objRecordSet.CursorLocation = adUseClient

	'Retrieve the user record from the database
	objRecordSet.Open strQueryString, objConnection, adOpenStatic, adLockPessimistic

    'Explicitly checks to see If there is a problem opening the table
    if err.number then
        Response.Redirect "Error.asp?number=" & err.Number & "&desc=" & Server.URLEncode(err.description) & "&Function=GetRecord&param=" & strQueryString
    End If
	on error goto 0

	'close the active connection
	Set objRecordSet.ActiveConnection = Nothing

	'return the disconnected recordset
	Set GetRecord = objRecordSet

	'Close the recordset and connection objects, and set them to Nothing.
	objConnection.Close
	Set objConnection = Nothing

End Function

thia was taken from a page called "global" in a folder called "includes"


hth

Nigel
 
One remaining question does seem to me - has the file path been confirmed?
i.e. apart from attempting to open a connection to it in your ASP - have you just confirmed the path (and considered Server.MapPath if required as mentioned).
 
Thanks for your input. Turns out the server I was given to host the ASP was on its way out. I now have a new server and It is working fine. Wish It happened before I went through all of this :)
 

Users who are viewing this thread

Back
Top Bottom