Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB Connection

Status
Not open for further replies.

jstickney

Technical User
Joined
May 25, 2004
Messages
4
Location
US
I am currently developing a page that is running on my local system and on a remote site. I need to be able to connect my ASP page to an Access database. I have always done this by hard coding the location or setting up a DSN in the control panel. My system and the remote site store the data in different locations, is it possible to map the locations some other way then hard coding or a DSN? I have included the locations on my local system and on the remote server that the ASP and Database will be located. I tried using MapPath to connect to the db but found that the MapPath method does not support relative path syntax. If anybody have any suggestions, they would be greatly appreciated.

My Local System
Database - c:\inetpub\domainroot\db\some.mdb
ASP - c:\inetpub\domainroot\public_html\some.asp

Remote System
Database - d:\inetpub\ASP - d:\inetpub\
 
MapPath method does not support relative path syntax

Just for clarification on that statement. Server.MapPath takes a relative or virt path and spits out the physical path.

That is exactly what it seems like you need in this case.

So in a DSN-Less connection you should be able to

Connection.Open(connection string & Server.MapPath(path)

You've tried this and it does not work?

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
Yes I tried using the following method but when I did it would return c:\inetpub\domainroot\public_html\some.mdb for the location.

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("some.mdb") & "
 
hmm..

How about using FSO to grab the path (ie GetAbsolutePathName and such returns)

Then you can also condition the fact that path may not be accurate on two seperate systems. As long as the driectory public_html is ever lasting (not going to change) you can do that process fairly quick without parsing the heck out of driectory after directory looking for the DB.

here is some reference to using FSO
FSO

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
Question: Why have two seperate databases for one app?

Or is this some sort of remote system with limited usage compared to a in house application?

How are you planning on reconciliation? Or are they not linked in any way?

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
I design on my local system and then upload to the client's server. Several times I have accidently uploaded the page with the db location for my local system. So I have to go back and modify the page for the customers server.
 
O' That's the reasoning for the paths.

Simply have two connections. Comment the production one out and then uncomment yours. When you upload simply switch the commented versions.

Then all you need to do is uncomment things instead of rewriting paths.

If this is a ongoing irritation, maybe session variables to hold the connection strings (NOT the connections) would help out. Then just change the global.asa and all is set

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
Commenting the lines out will work fine for the time being. My only fear is when and if the site moves to another server, somebody will need to make the modifications again. I can tell the customer to have their new provider setup the same basic structure (public_html, db) but the location and drive could very easily change. I am just trying to spare the customer any unnecessary downtime or expenses, if they make hosting changes in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top