
January 20th, 2006, 09:20 AM
|
 |
short arse brainiac
|
|
Join Date: Jun 2005
Location: Leeds UK
|
|
|
Auto build connstring for access databases
place these pages in the folder that holds your database, if within webroute. and it will build your database string for you.
the page
Code:
<%
dim strPath, strdbname ' define the variables
strdbName = Trim(Request.form("database")) 'ask for database name from the form
if strdbName <> "" then ' if the text box has something written
strPath = Replace(Request.ServerVariables("PATH_TRANSLATED"), "getstring.asp",strdbName) 'we get the path of the database, then place it in a string
end if %>
<html>
<head>
<title>were is my database</title>
</head>
<body>
<font face="Verdana,Arial,Helvetica" size="4">
<strong>database strings</strong></font><font face="Verdana,Arial,Helvetica" size="2"><b><%
if strdbName = "" then 'box was empty
response.write ("your must specify database name.mdb")
else
%>
</b>
<p><b>Physical Path to Database: <%=strPath%></b></p>
<p><b>Example strConnString:</b></p>
<p><b>for access 97, 2000 and up</b></p>
<nobr><p><b>strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<%=strPath%>" '## MS Access 2000</b></p></nobr>
<b>
<br /></b><p><b>if you cant get the above
to work, then below is your next option</b></p>
<nobr><p><b>strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=<%=strPath%>" '## MS Access 97</b></p></nobr>
<p></p>
<p></p>
<p></p>
<p><br>
If none work for you (strange) then you can use a DNS</p>
</font>
</body>
</html>
<% End IF %>
the form page
Code:
<html>
<head>
<title>database name including</title>
</head>
<body>
<form method="POST" action="getstring.asp">
<p>database name including .mdb <input type="text" name="database" size="20"></p>
<p> </p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
the asp page is to be saved as getstring.asp
unless you change the action on the form
hope this helps with novice, and first time database users and asp
Last edited by minus4 : January 20th, 2006 at 09:41 AM.
|