[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
ASPFAQ_Use_MapPath_in_Database_Connection
Place this script in the top of your ASP page where you access the database from.
Or better, if you save this script an asp file eg. connection.asp, then you can reference it from any ASP page. Make sure the ConnectionString appears on a single line.
Placed this script in the top of every ASP file that you want to have a database connection.
The adovbs.inc is a file that comes with IIS. This file has all of the ADO constants defined which are needed when connecting to databases.
Related threads:
how to set a path for database?
Back to ASP FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
ASPFAQ_Use_MapPath_in_Database_Connection
How to use Server.MapPath in an MS Access database connection?
The MapPath method maps a relative or virtual path to a physical path. It can be useful when you are not sure of the exact path of the database you want to connect to. If you move a database file to another drive but the directory structure on the two drives are the same, then using MapPath the connection will work.Place this script in the top of your ASP page where you access the database from.
<%
Set Conn=Server.CreateObject("ADODB.Connection")
ConnectionString="DBQ=" & Server.MapPath("entries.mdb")
Conn.Open "DRIVER={Microsoft Access Driver(*.mdb)};" & ConnectionString
%>Or better, if you save this script an asp file eg. connection.asp, then you can reference it from any ASP page. Make sure the ConnectionString appears on a single line.
Placed this script in the top of every ASP file that you want to have a database connection.
<% @Language=VBScript%> <% Option Explicit %> <!--#include file="adovbs.inc"--> <!--#include file="connection.asp"-->
The adovbs.inc is a file that comes with IIS. This file has all of the ADO constants defined which are needed when connecting to databases.
Related threads:
how to set a path for database?
Back to ASP FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
