
CFQuery with Blank Username and Password
I am in a situation where my application may sometimes have datasources with the username and password specified, and other times needs to have the username and password specified in the CFQuery tag. The quandary being how to have one cfquery tag that supports both. The ColdFusion documentation says that the username and password in cfquery are optional, but if specified overwrite the datasource username and password. But what if they are specified blank?
It turns out that if you have nothing in the username or password, but do have them in your cfquery, then the datasource username and password is used after all.
So:
2<cfset p = "">
3<Cfquery name="getstuff" datasource="#application.datasourcename#" username="#u#" password="#p#">
4Select RecordA, RecordB, Record_Blah
5From MyTBL
6</Cfquery>
Works just fine against a datasource that has the user/pass already defined and putting in the user and pass will satisfy the other need as well.

NAVIGATION
HomeAbout Me
RSS
Search
Subscribe
Recent Entries
Flash Camp BostonNew Blog Design
Pre-Conference Training at cf.Objective()
FireFox 3.6 KTML Editor Fix
I am now a part of the Adobe Community Professionals Group
Recent Comments
FireFox 3.6 KTML Editor Fix
Joshua said: While changing that far will load the editor, does it show the drop down class menu correctly now?
[More]
FireFox 3.6 KTML Editor Fix
Al Johnson said: HI,
I am still fighting to keep my code going as there is nothing better than KTML nad I have writt...
[More]
Google Chrome Review
web development said: ow there are all kinds of cool architectural ideas around Google Chrome, but right now, they don't m...
[More]
FireFox 3.6 KTML Editor Fix
wayne said: i have been having issues with the code editor myself, it seems i can no longer copy and paste or th...
[More]
submiting a form inside an iframe from outside the iframe
Peter said: I doubt you’re still having this problem over 2 years later, but if anyone else finds this page on t...
[More]
Calendar
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Archives By Subject
blogs (31) [RSS]books (4) [RSS]
Crazy (39) [RSS]
DIY (8) [RSS]
Flex (3) [RSS]
games (10) [RSS]
GRRR (13) [RSS]
Ideas (11) [RSS]
Local (14) [RSS]
LOLpics (2) [RSS]
money (9) [RSS]
music (3) [RSS]
Personal (27) [RSS]
Photos (8) [RSS]
Politics (8) [RSS]
Projects (22) [RSS]
Review (18) [RSS]
RPM (9) [RSS]
Spam (16) [RSS]
Technology (66) [RSS]
Testing (3) [RSS]
TV (15) [RSS]
video (32) [RSS]
Web Dev (218) [RSS]
World of Warcraft (16) [RSS]

There are no comments for this entry.
[Add Comment] [Subscribe to Comments]