Connecting to an Access DB using a connection string (not ODBC)

Article No. 79
Created: 01:53 AM 04.16.04
Author: Support
Original URL: http://myonlinehostingsupport.com/question.php?qstId=79


//**************************************
// Name: Dynamic CFquery's with Access
// Description:Connect to your Access da
// tabase using a connection string instead
// of ODBC
// By: Steve Oliver
//
// Inputs:connection string
//
// Side Effects:Only works on CF5.0
//
//This code is copyrighted and has
// limited warranties.Please see http://
// www.Planet-Source-Code.com/xq/ASP/txtCod
// eId.38/lngWId.9/qx/vb/scripts/ShowCode.htm for details
//
//**************************************

This will go in your Application.cfm.

<!--- enter your dbase name here --->
<cfset REQUEST.dbase = "leads.mdb">
. <!---gets directory that application.cfm is in --->
<cfset REQUEST.directory = "#getDirectoryFromPath(getCurrentTemplatePath())#">
.
<!---sets the connection string --->
<cfset REQUEST.connectstring = "Driver={Microsoft Access Driver (*.mdb)}";
Dbq=#REQUEST.dbase#;
DefaultDir=#REQUEST.directory#;
Uid=;
Pwd=;>
.
.
.
And this will go wherever you want to make a query.
.
<cfquery name="qryName" dbtype="dynamic" connectstring="#REQUEST.connectstring#">
SELECT * FROM tbl
</cfquery>

Back to original article