Login | Register   
RSS Feed
Download our iPhone app
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 14, 2000



Application Security Testing: An Integral Part of DevOps

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 %>
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>"
set conn=Nothing
set RS=Nothing
Ken Cox
Comment and Contribute






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



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date