Cold Fusion 5 DSN-less connection

** CFMX6 and higher does not support DSN-less connection strings.

The first thing that you need to do is set a variable called: MyConnectionString

You can do this as follows:

<cfset MyConnectionString = "

Driver={Microsoft Access Driver (*.mdb)};

Dbq=MyDatabase.mdb;

DefaultDir=D:\path2files\;

Uid=Admin;

Pwd=Password;">

Note: there cannot be a space in the actual code, we had to place a space for formatting

reasons!
Changing the MyDatabase.mdb to the name of your database file, then the d:\path2files\ to the

path on the server to your file, and finally the username and password. I suggest that you

specify this in your application.cfm is you will need this throughout your website, otherwise

leave it on the same page as the where the tag will call for it.

The next change needed is to alter the tag a little different than usual. there is a

value that you always pass in that is titled datasource="".... this will be absent as

you are not really connecting to a datasource, but instead an actual direct database connection.

Below you see a working example of the modified, faster working tag.

<cfquery name="GetExample"
connectstring="#MyConnectionString#"

dbtype="DYNAMIC">

Select *

From tablename

Order by fieldname

</cfquery>

Add Feedback