Whenever I get the error from using SELECT * and cfqueryparam and adding
columns it's not that error. Usually CF7, SQL Server 2000 if that matters.

Adrian

-----Original Message-----
From: Peterson, Chris [mailto:[EMAIL PROTECTED]
Sent: 10 April 2007 14:23
To: CF-Talk
Subject: RE: Could not find prepared statement with handle 2 - suddenly?


Dan,

I think you hit the nail on the head there, I'm sure that's what was
going on, as it looks like a column was added to that table.  Its always
fun to look at code you did in the past, even 2 months ago I look at
some code and go 'oh man, why didn't I do X'.

Quick re-coding time =)

Chris Peterson
-----Original Message-----
From: Dan G. Switzer, II [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 10, 2007 9:09 AM
To: CF-Talk
Subject: RE: Could not find prepared statement with handle 2 - suddenly?

Chris,

><cfquery name="getReportInformation" datasource="Reports"> SELECT *
>FROM runReports WHERE Reportnumber = <cfqueryparam
>cfsqltype="cf_sql_varchar"
>value="#trim(url.report)#">
></cfquery>
>
>I removed the cfqueryparam, and it starts working perfectly.  Why would

>this break all the suddon?  Any idea's?

Using <cfqueryparam /> tags and the "select *" directive, can cause
problems if you insert a new column into your table. If you insert the
column between existing columns, the cache query plan used by the report
all of the sudden becomes corrupt.

This is one of many reasons it's recommended not to use "select *" when
querying data. Always explicitly set the columns you need in your code.
In the long run, it'll make your coding life easier.

-Dan



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & 
Flex 2
Free Trial 
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:274934
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to