dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: All
Jan 15, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Let ASP's Server.MapPath Find Your Database

When you use a "DSN-less" data connection to a Microsoft Access database, you must provide the physical path to the database. If your files are kept on your ISP's Web server, you may have trouble keeping track of the disk drive and path. However, you can let Active Server Pages locate your database for you. Just hand the virtual directory name to the Server.MapPath() method and let it return the physical path. After that, concatenate the connection string as shown in the following ASP code. In the sample, /work_p450/ is the virtual directory and empemail.mdb is the database name.

 
<%@ Language=VBScript %>
<HTML>
<BODY>
<%
set conn=server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};" & _
 "dbq=" & Server.MapPath("/work_p450/empemail.mdb") & ";" & _
 "uid=admin; pwd="
set RS = conn.Execute( _
	"SELECT * FROM Employees " _
	& "ORDER BY LastName, FirstName")
while not RS.eof
 Response.Write RS("LastName") & "<BR>"
 RS.movenext
wend
set conn=Nothing
set RS=Nothing
%>
</BODY>
</HTML>
Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date