[Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 1.
I'm getting this error message in what appear to be random ways. The first time I look at a page I might not get it, but the second time I might. I discovered that removing a cfqueryparam tag worked, but that is not really a safe solution. I checked that the cf_sql_type matched the database field, and in one case changed a cf_sql_varchar to a cf_sql_char so it would match a SQL Server nchar(10) field. But still these errors. Any ideas? I've not had any luck Googling this.
I should add that I'm running Coldfusion 9 as a Tomcat webapp on a Linux server. The database is SQL Server 2005, I think.
It's possible there's something in my logic that is doing that ... but it was happening to one query that was referring to a value set at the top of the file (via cfqueryparam) and when I removed that cfqueryparam it started to happen to a different query. And, I should add, the queries in question were working fine for years before on a coldfusion MX server. This is a new page in the app, but the queries are all being included from old working template files.
Here's the one that is breaking now:
<cfquery name="CheckCredentials" datasource="#application.crossreg_dsn#">
SELECT [name_first]+' '+[name_last] as name
,p.[uni]
,p.email
,p.role_id
,r.role_name
,p.external_program_id
FROM [CrossReg].[dbo].[People] p
INNER JOIN dbo.Roles r on r.role_id = p.role_id
WHERE uni = <cfqueryparam cfsqltype="cf_sql_char" value="#Session.username#">
</cfquery>
Session.username is being returned from a CAS authentication system. I've never had troubles with it before.
Just to let you know that you are not crazy, I have had the same issue in CF9 (standard Windows install) with SQL Server 2005. I also have not found a solution, and in all cases I have had to remove the <cfqueryparam> tag. Restarting CF (or, alternately, restarting SQL Server) solves the problem temporarily, but after a few days it always comes back.
If you come across a solution, please update this post!
I had the same problem due to a query that errored then all subsequent queries would error as well with this error message
I found this blog post regarding this issue:
http://www.sstwebworks.com/entry.cfm?entry_id=AAF6E42A-F14A-4716-88B98 BD231596CA6
North America
Europe, Middle East and Africa
Asia Pacific