Click to See Complete Forum and Search --> : server cursor cannot be opened on the given statement or statements


scouse
04-25-2008, 05:31 AM
Hi,

Not sure if this should be in the SQL forum or here as its a bit of both I think.

Basically I'm in the process of going through my website replacing all the SQL statements with stored procedures. One of the ones I'm doing keeps causing an error, but I can't work out why.

The original SQL statement is:


sql="SELECT * FROM DATABASENAME.dbo.buyers_guides WHERE bg_id="&request.querystring("bg")

set rs=conn.execute(sql)
bg_title=rs("bg_title")
bg_content=rs("bg_content")
bg_title_long=rs("bg_title_long")
rs.close


This is the new call to the stored procedure that replaces the select statement

sql="exec DATABASENAME.dbo.buyers_guides.sp_pr_buyers_article "&request.querystring("bg")&""


and this is the stored procedure

CREATE PROCEDURE sp_pr_buyers_article
@bg_id INT

AS
SELECT
bg_id,
bg_title,
bg_content,
bg_title_long,
bg_order
FROM
buyers_guides
WHERE
bg_id = @bg_id

GO


but this is the error it keeps producing:

[Microsoft][ODBC SQL Server Driver][SQL Server]A server cursor cannot be opened on the given statement or statements. Use a default result set or client cursor.



I've had a look on google, but can't really make a lot of sense of what is causing the error

Any help would be great

Thanks