Sproc with temp tables and input parameters causing trouble with dynamic recordsets - a tricky one!
From: John Hoge (jhoge123_at_yahoo.com)
Date: 03/24/04
- Next message: toylet: "Re: unique temp table name"
- Previous message: Dan Guzman: "Re: calling Stored Procedures from different DBs"
- Next in thread: Adam Machanic: "Re: Sproc with temp tables and input parameters causing trouble with dynamic recordsets - a tricky one!"
- Reply: Adam Machanic: "Re: Sproc with temp tables and input parameters causing trouble with dynamic recordsets - a tricky one!"
- Messages sorted by: [ date ] [ thread ]
Date: 24 Mar 2004 05:40:21 -0800
In a web application I need to call a stored procedure that lists
items in a shopping cart. The Sproc is pretty complicated as it needs
to do compatibility checks between the items in the cart, and makes
use of temporary tables. It has one parameter, the order ID.
The problem lies when the recorset needs to be opened in any
non-forward only mode, such as static, dynamic or keyset. This is
needed because the checkout page contains script to compose an email,
so the recordset needs to be looped through twice.
It seems the recordset.moveFirst command will cause this error
Microsoft OLE DB Provider for ODBC Drivers error '80040e18'
Rowset position cannot be restarted.
in any situation where a stored procecure including a temporary table
is called, and a parameter is passed. Take a look at the Sproc below:
create proc usp_test(@id int) as
select @@version as version into #test
select * from #test
Pretty simple. It makes a temp table and spits it out. When called by
the vbscript code below, it produces the above error. I've tried this
both on SQL7 and SQL2000.
set ordItemsRS = server.createObject("ADODB.RECORDSET")
with cmdorderItems
.activeConnection = "DSN=SeaEagle"
.commandType = adCmdStoredProc
.Commandtext = "usp_test"
.Parameters.Append .CreateParameter("@ord_id",adInteger,adParamInput,,25075)
end with
ordItemsRS.open cmdOrderItems, ,adOpenStatic ,adLockReadOnly
do while not ordItemsRS.eof
response.write ordItemsRS("version") & "<br>"
ordItemsRS.moveNext
loop
ordItemsRS.moveFIrst
- Next message: toylet: "Re: unique temp table name"
- Previous message: Dan Guzman: "Re: calling Stored Procedures from different DBs"
- Next in thread: Adam Machanic: "Re: Sproc with temp tables and input parameters causing trouble with dynamic recordsets - a tricky one!"
- Reply: Adam Machanic: "Re: Sproc with temp tables and input parameters causing trouble with dynamic recordsets - a tricky one!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|