Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with DSN-less Connection CFC

Status
Not open for further replies.

Glowball

Programmer
Oct 6, 2001
373
US
Hi all, I have the DSN-less connection working so I can connect to a database without needing a datasource defined in ColdFusion Administrator. Now I'm trying to put the functionality into a CFC so users can call it to connect, then send queries to it and get back recordsets.

I have a method that will connect to the database -- that's working. The issue is the next method that queries the connection. How do I pass that connection from one method to the other?

The first method basically does this at the end:

Code:
<cfobject type="COM" name="methodConn" class="ADODB.Connection" action="CREATE">   
<cfset dsn = "DRIVER=#Driver#;SERVER=#ARGUMENTS.hostname#;DATABASE=#ARGUMENTS.database#">
<cfset thisConn = methodConn.Open("#dsn#", "#ARGUMENTS.username#", "#ARGUMENTS.password#", -1)>

Should I return something? What's the type?

The next method will take a SQL string like the following, but what do I put in the "UNKNOWN" part?

Code:
<cfset recordset = UNKNOWN.Execute(ARGUMENTS.sql, 0, 8)>

I'm not sure how to tie these things together, so any pointers would be very appreciated. Thanks!
 
I think maybe I didn't explain this very well. Basically one method opens a database connection and another method queries the database through that connection. I can't figure out how the second method can know about the result of the first method (the connection).

Is anyone doing anything like this?
 
Thanks for the link, but I do have it working just fine. It was the CFC I was having a problem with, but I've figured a little something out. It's not 100% perfect but when it is I'll put it in the FAQs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top