Friday, November 14, 2003

I remember a while ago I saw an article explaining the importance of hiding the DataSource names in your ColdFusion queries. So I searched the web and it took me ages to find this info so I thought I would share it for any CF newbies out there.

First of all in your Application.cfm file add the following code: (blogger would not allow me to post the surrounding tags so I have replaced them with [ ] anyone know how to get around this?)

[CFSET request.DSN = "yourDSN"]

Then simply change your queries in your CFM pages to read:

[cfquery name="Recordset1" datasource="#request.DSN#"
SELECT * FROM products WHERE prodCatIDFK =
cfqueryparam value="#URL.prodCatID#" cfsqltype="cf_sql_char"
/cfquery]

Also notice the use of which I introduced after reading Ben Forta's article, a must read!

Jon 9:35 AM Permalink

Comments:

Post a Comment