Sounds like a solid plan, my friend.

We affixed a single DSN to DatabaseBlocks for simplicity's sake, but we'll
be happy to provide an "approved hack" for this on
ProductivityEnhancement.com by adding the additional optional arguments to
DatabaseBlocks methods in a customized DatabaseBlocks.cfc.

I know some people always pass such things into their methods, but we
weren't going to be obsessive about this when we designed the product.  We
may need to rethink that in the future, though.

Thanks, Tim.

Respectfully,

Adam Phillip Churvis
Member of Team Macromedia
http://www.ProductivityEnhancement.com

Download Plum and other cool development tools,
and get advanced intensive Master-level training:

* C# & ASP.NET for ColdFusion Developers
* ColdFusion MX Master Class
* Advanced Development with CFMX and SQL Server 2000

----- Original Message ----- 
From: "Tim Blankenship" <[EMAIL PROTECTED]>
To: "Plum Email List" <[email protected]>
Sent: Thursday, May 19, 2005 4:10 PM
Subject: [plum] databaseblocks DSN question - Alter Framework


Alright I have a PLUM app that has 2 DSN connections.
I added the seconf one in enviornment.cfm as follows
Application.db2DSN = "INSIGHT";
Application.db2Username = "user";
Application.db2Password = "pass";
I have a page that I need to query the added DSN.
Here is a query I use.

<cfquery datasource="#application.db2DSN#" name="qry_memoryimport">
SELECT R_DIMMSlots.DeviceName,
R_DIMMSlots.MemorySize
FROM R_Inventory INNER JOIN R_DIMMSlots
ON R_Inventory.DeviceName = R_DIMMSlots.DeviceName
WHERE R_Inventory.SerialNumber = '#URL.SN#'
</cfquery>

But what I want to use is..

<cfscript>
selectClause = "R_DIMMSlots.DeviceName, R_DIMMSlots.MemorySize";
fromClause = "R_Inventory INNER JOIN R_DIMMSlots ON R_Inventory.DeviceName =
R_DIMMSlots.DeviceName";
whereClause = "R_Inventory.SerialNumber = '#URL.SN#''";
qry_memoryimport = Application.DatabaseBlocks.SelectRecords
(selectClause:selectClause,
fromClause:fromClause, whereClause:whereClause);
</cfscript>

Problem is where do I specify the DSN since it defaults to in the cfc to
#application.db2DSN#.
Proposed solution is to add new arguments to databaseblocks.cfc

<cfargument name="DSNName" type="string" required="No"
default="#Application.dbDSN#">
<cfargument name="DSNUsername" type="string" required="No"
default="#Application.dbUsername#">
<cfargument name="DSNPassword" type="string" required="No"
default="#Application.dbPassword#">

Change
<cfquery name="queryResult"
datasource="#Application.dbDSN#"
username="#Application.dbUsername#"
password="#Application.dbPassword#"
cachedWithin="#Arguments.cacheTimeSpan#">
to
<cfquery name="queryResult"
datasource="#Attributes.DSNName#"
username="#Attributes.DSNUsername#"
password="#Attributes.DSNPassword#"
cachedWithin="#Arguments.cacheTimeSpan#">

My query would know (hopefully) work like this

<cfscript>
DSNName = "#application.db2DSN#";
DSNUserName = "#Application.db2Username#";
DSNPassword = "#Application.db2Password#";
selectClause = "R_DIMMSlots.DeviceName, R_DIMMSlots.MemorySize";
fromClause = "R_Inventory INNER JOIN R_DIMMSlots ON R_Inventory.DeviceName =
R_DIMMSlots.DeviceName";
whereClause = "R_Inventory.SerialNumber = '#URL.SN#''";
qry_memoryimport = Application.DatabaseBlocks.SelectRecords(DSNName:DSNName,
DSNUsername:DSNUsername, DSNPassword:DSNPassword,selectClause:selectClause,
fromClause:fromClause, whereClause:whereClause);
</cfscript>

Thoughts or opinions? Is there a better way?

-- 
Tim Blankenship
[EMAIL PROTECTED]
www.vespri.com <http://www.vespri.com>


**********************************************************************
You can subscribe to and unsubscribe from lists, and you can change
your subscriptions between normal and digest modes here:

http://www.productivityenhancement.com/support/DiscussionListsForm.cfm
**********************************************************************

Reply via email to