ColdFusion 5.0 bring a new and existing feature
known as DNS-Less connections. In the ASP world it's been available for a
while, so in the standards of making ColdFusion bigger and better then it's only
understood that Macromedia would create a similar (yet, easier to use) way of
doing things!
This new and exciting tool uses a new setting
that must be in place in your <CFQUERY> tag.
The best thing that you can do is to first 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 This colored text to the name
of your database file, then this colored text
to the path on the server to your file, and finally the username and password if
your database is password protected (this one is optional, if not leave as is!).
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 <cfquery>
tag will call for it.
The next change needed is to alter the <cfquery>
tag a little different than usual. there is a value that you always pass in
<cfquery> 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 <cfquery> tag.
<cfquery name="GetExample"
connectstring="#MyConnectionString#"
dbtype="DYNAMIC">
Select *
From tablename
Order by fieldname
</cfquery>
That's it, this is the best example I could
possibly give you on how to use a dynamic <cfquery>
connection.
Date added: Fri. August 16, 2002
Posted by: Pablo Varando | Views: 23425 | Tested Platforms: CF5 | Difficulty: Intermediate
Best Practices
Databases
 |
SQL
how to do the same with SQL server
Posted by: Asim
Posted on: 06/16/2004 12:46 PM
|
Number of DSNs
If I were to get a host that only allowed a certain number of DSNs, would using this code mean that I could use as many as I wanted to?
Posted by: tsuukai
Posted on: 07/09/2004 08:47 PM
|
need to have the full code
hi,
i would like to connect to ms sql server database using coldfusion program. i could connect database without any problem don't know hoow to retreieve records from my table created in ms sql..
i would appreciate if you could provide me with all possible coding...
thanks in advance..
Posted by: how to connect to ms sql databse from clodfusion
Posted on: 06/23/2005 05:16 AM
|
No More Connectionstring with Coldfusion
Macromedia coldfusion have stopped using this tag after CF 5. Bad or Good?
Posted by: Mayoorathen
Posted on: 07/01/2005 01:38 AM
|
something I found/read...
After reading this article I thought I was all set. But I am developing my applications in ColdFusion MX 7 and encountered the error below: "The tag does not have an attribute called connectstring. The valid attribute(s) are name, datasource, dbtype, sql, username, password, maxrows, blockfactor, timeout, dbname, cachedafter, cachedwithin, result, debug."
Much to my dismay, I found that Macromedia added "connectionless" DSN's in CF 5, then took them away again in CFMX. Further researching this, I found out that this is because ColdFusion MX 7 no longer interfaces directly through ODBC. Instead it uses JDBC as the data access layer.
I have yet to find a work around, So I will continue to setup my DSN references via the ColdFusion Administrator Interface.
Posted by: Charlie Seitz
Posted on: 05/08/2006 05:02 PM
|
database file
HI there, is it possible to use the MyConnectionString DefaultDir=D:\path2files\; so it would connect to a .mdb file somewhere on the internet remotely like http://www.somesite.com/data ? Basically is there a way that Cf could connect to any .mdb file anywhere on any server? PLease help..Many thanks AKos
Posted by: Akos
Posted on: 02/06/2008 03:23 AM
|
|