Can anybody tell me why a) when running a stored proc from an asp page to
return a recordset the command succeeds if the sp queries an existing table
directly, but b) if the stored proc populates results into a different
table, temporary table, global temp table, or table variable, then queries
one of these, the asp page reports that the recordset object is closed. If
using a table, I have set grant, select, update, delete permissions for the
asp page user account, so it doesn't appear to be a permissioning issue. If
run in Query Analyser the sp runs fine of course.
Abridged asp code is as follows:
StoredProc = Request.queryst ring("SP")
oConn.Connectio nString = "Provider=SQLOL EDB etc"
oConn.Open
set oCmd = Server.CreateOb ject("ADODB.Com mand")
oCmd.ActiveConn ection = oConn
oCmd.CommandTex t = StoredProc
oCmd.CommandTyp e = adCmdStoredProc
oCmd.Parameters .Refresh
'code here that populates the parameters of the oCmd object correctly
Set oRs = Server.CreateOb ject("ADODB.Rec ordset")
With oRS
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOpti mistic
'execute the SP returning the result into a recordset
.Open oCmd
End With
' Save data into IIS response object
Response.Conten tType = "text/xml"
oRs.Save Response, adPersistXML
'the line above fails with stored procs from example B below, reporting "not
allowed when object is closed", but works with example A
SP Example A - this one works fine
Create Proc spTestA AS
SELECT ID FROM FileList
GO
SP Example B - this one doesn't work from ASP but runs fine in QA
Create Proc spTestB AS
DECLARE @Results Table (ID TinyInt)
INSERT INTO @Results SELECT ID FROM FileList
SELECT ID FROM @Results
GO
I can see the SP executing using profiler when the asp page is called for
both sp's above, so it doesn't appear to be a problem with the execution.
It's something to do with returning the result set from the table variable.
Thanks,
Robin Hammond 1 3140
"Robin Hammond" wrote:
<snip> SP Example B - this one doesn't work from ASP but runs fine in QA Create Proc spTestB AS DECLARE @Results Table (ID TinyInt) INSERT INTO @Results SELECT ID FROM FileList SELECT ID FROM @Results GO
<snip>
Robin,
The problem is that you're getting back a closed recordset with "records
affected" info from SQL Server: using the NextRecordset method in ADO will
get the actual recordset you're looking for. A good rule of thumb is to
watch the output from a stored proc in QA: anytime you see a resultset or a
message about records affected, then you know this could pop up.
A more efficient solution (and the one I prefer) if you don't need any data
back but the result of the SELECT is to use SET NOCOUNT...
Create Proc spTestB AS
SET NOCOUNT ON
DECLARE @Results Table (ID TinyInt)
INSERT INTO @Results SELECT ID FROM FileList
SET NOCOUNT OFF
SELECT ID FROM @Results
GO
Craig This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matthew Louden |
last post by:
The following ASP code yields the following error, but actually the new
record is stored
in database. The same error happens when the application deletes a record,
such as
sqlStmt ="delete from test where username='2323'" Any ideas? Thanks!
<%
Dim objRS, sqlStmt
Set objRS = Server.CreateObject ("ADODB.Recordset")
sqlStmt = "insert into test VALUES ('2341', '2341');"
|
by: Eli Sidwell |
last post by:
Trying to return a Recordset to an ASP and the Recordset is empty.
The StorredProc works in the query analyzer and it even works from a
quick VB app that I wrote to test it.
The storedproc that I am using is fairly complex (creates some
temporary tables and populates them with 'Insert Into Select ...', but
the during testing the only Select statements that return visible rows
is the final one that returns the finished table with an...
|
by: JackV |
last post by:
Hi All,
I have a pure asp (Vbscript) page that manipulates data between MSAccess and
SQLServer2000. I'm trying to use the Scheduler app on the IIS server to run
this page nightly but there must be a better way of doing this.
How can I make my code in to an object and install it on the server and have
it schedule to run nightly?
|
by: (Pete Cresswell) |
last post by:
I posted this in the MS Access group, but no luck.
------------------------------------------
I've got another stored procedure in the same app that returns multiple
recordsets and the code works.
But now I've written another SP and the code traps out with the 3251 message.
The SP is writing two recordsets.
When I run the SP in Query Analyzer, both recordsets appear.
|
by: rhungund |
last post by:
Hi All. My question is this. I have a complex stored procedure in SQL
Server which works fine when I run it in Query Analyzer. However, when
I call it within my ASP script, it returns nothing, and sometimes locks
up. If I change my script to call other existing stored procedures it
works fine. It's just with this particular stored proc. I have tried
various DB calls in ASP, such as opening the recordset through an ADO
connection and...
| |
by: dkode8 |
last post by:
Heres my problem, the first part selects a row from the database, if
there is no row with the criteria it inserts a row and then returns it,
the problem is the IF statement that inserts the row, never returns the
select after it. if there is a row initially in the database, it
returns the right information, I just can't get it to return the row
after inserting it. Anyone know what the problem could be?
Stored procedure:
ALTER...
|
by: lenny |
last post by:
Hi,
I've been trying to use a Sub or Function in VBA to connect to a
database, make a query and return the recordset that results from the
query. The connection to the database and the query works fine, but
passing the resulting recordset back to the sub's caller is not working
out.
|
by: isaac2004 |
last post by:
hi i am trying to use the record count object to count the number of
books in a database of mine. i get this error saying that i have closed
the object and i dont think i closed it. here is my code
<% dim strBrowse, strSearch, Count
Count = objRS.RecordCount
strBrowse = request.querystring("strBrowse")
|
by: rsmccli |
last post by:
Access 2002
Hi. I have a command button that will "approve" all records currently being looked at by an "approver". For some reason, even though there are multiple records that exist in the recordsetclone, EOF is returning true. I think this may have something to do with the sort order of the underlying query, but I'm not sure; at any rate, I don't want to change the sort order. I thought you had to check for BOF and EOF, or at least EOF before...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |