Important alert: (current site time 7/16/2013 6:43:10 AM EDT)
 

article

DNS-Less connections

Email
Submitted on: 9/15/2006 7:46:29 AM
By: FusionerMX  
Level: Beginner
User Rating: Unrated
Compatibility: Cold Fusion 5
Views: 11326
author picture
(About the author)
 
     ColdFusion 5.0 bring a new and existing feature known as DNS-Less connections.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				

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.



Other 19 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
9/28/2006 2:07:05 AMIrshad

i want to retrieve the Ms Access database from the server using VB.net alpplication, in asp.net application we retrieve the database from the server using server.mappath, but in vb.net (Desktop Application) i don't know how to do it? please help me i am in very trouble, i have the ip address of that server. plz plz help me.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.