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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm doing (done?) out a site in DW

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I'm doing (done?) out a site in DW Ultradev 4. I just noticed today that the connection string that it creates (DSNless) refers to the c: drive as below.
<%
' FileName=&quot;Connection_ado_conn_string.htm&quot;
' Type=&quot;ADO&quot;
' HTTP=&quot;true&quot;
' Catalog=&quot;&quot;
' Schema=&quot;&quot;
MM_newsconnect_STRING = &quot;DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=c:/inetpub/%>

When I try to change this to a relative path (DBQ=database.mdb) it doesnt work.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
/sitename/careers.asp, line 5

Any help really appreciated
Killian
 
Hi

You need a fullpath for a dsnless connection, whether it is local or remote. But here is a super piece of code for checking and deciding on what to make your dsnless connection. Create a new file in your connections folder and pop this in it:

Code:
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<%
dbname    = &quot;\yourdatabase.mdb&quot;  ' database name
locfolder = &quot;htdocs\&quot;            ' folder the mappath is returning
newfolder = &quot;private\&quot;           ' folder to change it to
%>
<html>
<head>
<title>DSNless creation</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<p>Path to selected database = &quot;<%=(server.mappath(dbname))%>&quot;</p>
<p>Adjusted path for string = &quot;<%=replace(server.mappath(dbname),locfolder,newfolder)%>&quot;</p>

<% MM_conn_STRING = &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot; & replace(server.mappath(dbname),locfolder,newfolder) %>
Your string should be : <%=MM_conn_STRING%>
</body>
</html>

Post that to your webserver and run it. Basically, we use server.mappath() to get a full path to a selected file, but due to the relative nature of the site, and which folder you are calling it from this can frequently be different to the folder your database is in.

The Path to selected database bit is what is returned from the straight server.mappath, so to adjust this to the location we want to replace the folder names with the correct ones. This is where &quot;locfolder&quot; and &quot;newfolder&quot; come in. Usually you will end up replacing &quot;public-html\&quot; with &quot;private\&quot;.

I can hear doubt ... try it and see what I mean. Of course you could just use the server.mappath to do it and simply hard code the thing, but I find that if the site is moved then the relative nature of this code is always successful. Derren
[Mediocre talent - spread really thin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top