Question

I have just been assigned an inherited coldfusion project. The developer dropped everything and left. Can someone point me to a good post or explain to me how to connect to a SQL database? I am using coldfusion builder and I have ftp'ed into the files but I am not sure where to create the connection to the database. Does CF builder have a connection wizard?

Was it helpful?

Solution

You don't define ColdFusion connections in code, like in other languages. You define them at the server level, using the ColdFusion Administrator, which is a web-based interface:

http://yourserver/CFIDE/administrator (you'll need the password)

What you're looking for is the "Datasources" option on the left. The exact parameters you'll use will vary by database driver of course, but the options should be familiar, if you've defined datasources before in languages like PHP or C#.

Then you create a query like so:

<cfquery name="myRecordsetName" datasource="myDatasource">
    select somecolumn from sometable
</cfquery>

(CF 9.0+ you can omit the datasource parameter and define in Application.cfc).

Then you can work with the recordset in a number of way (loop over output, etc)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top