[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
ASPFAQ_Connect_to_MSAccess_ADODB

How to connect to an MS Access database using ODBC?

ODBC stands for Open DataBase Connectivity and is a layer that provides a standardised method of data access.

ADODB is based on Microsoft's ADO (ActiveX Data Objects) data-access method which is used to connect, navigate and manipulate different databases.

Place the following script in your ASP page. The example is for an MS Access Database. Note that the DBQ Parameter holds the connection location of the database to be used.

For more information about Connection Strings for MS Access and other databases, please see : ConnectionStrings.Com

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString="DRIVER={Microsoft Access Driver(*.mdb)};DBQ=D:\lillu\entries.mdb;Uid=;Pwd=;" 
Conn.Open
%>


Or better, if you save this script in its own asp file eg. connection.asp, then you can reference it from any ASP pages. Make sure the ConnectionString appears on a single line.

Set the relevant user id (Uid) and password (Pwd) properties in the ConnectionString. If there are no such settings, leave them as is.

Placed the following 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:
plz help!! Access into MS Access Database

Back to ASP FAQ

last edited (May 4, 2004) by leeos, Number of views: 3546, Current Rev: 8 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.