473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Getting records and output parameter from ASP

I have a need for a stored procedure to return a recordset AND an output parameter that contains the count of records in the recordset.

I can get either but not both. (ie. if there is a select then there is no output parameter)

The stored procedure is:

ALTER PROCEDURE test
(
@Msgs nvarchar(150) OUTPUT
)

As
declare @selCount int
SELECT folderLocation, externalDocsID from externalDocs

set @selCount = @@ROWCOUNT
IF @@ROWCOUNT = 0
BEGIN
SET @Msgs = 'No folders meet this selection criteria'
RETURN
END
else
BEGIN
SET @Msgs = @selCount
END
return

----------------------------------------------------------------------------------

the asp code is

Dim cnnStoredProc ' Connection object
Dim cmdStoredProc ' Command object
Dim rstStoredProc ' Recordset object
Dim folderText
Set cnnStoredProc = Server.CreateObject("ADODB.Connection")
cnnStoredProc.Open db
' get the correct records for a page
Set cmdStoredProc = Server.CreateObject("ADODB.Command") ' Create Command object we'll use to execute the SP
cmdStoredProc.ActiveConnection = cnnStoredProc ' Set our Command to use our existing connection
cmdStoredProc.CommandText = "test" ' Set the SP's name and tell the Command object
cmdStoredProc.CommandType = adCmdStoredProc
cmdStoredProc.Parameters.Refresh

' ---------- SET PARAMETERS ----GET A PAGE WORTH OF RECORD--------------------------------------------------------------------
set prop=ADODB.Parameter
cmdStoredProc.Parameters("@functionCode").Value = "L" 'functionCode
cmdStoredProc.Parameters("@customerID").Value = customerId 'CustomerID
if searchCriteria <> "" then
cmdStoredProc.Parameters("@searchcriteria").Value = searchCriteria 'search string
end if
if showAssigned = "Y" then
cmdStoredProc.Parameters("@excludeDefined").Value = "Y" '
end if
set rstStoredProc = cmdStoredProc.Execute
'

response.write("msgs=" & cmdStoredProc("@Msgs")) ' <<<<<<< THIS DOESN'T WORK--------------------------------------------------------------------------------------------------

I can enumerate through the recordset but the output parameter is blank.

Any Ideas

Thanks
Jul 23 '07 #1
1 5980
ck9663
2,878 Expert 2GB
I have a need for a stored procedure to return a recordset AND an output parameter that contains the count of records in the recordset.

I can get either but not both. (ie. if there is a select then there is no output parameter)

The stored procedure is:

ALTER PROCEDURE test
(
@Msgs nvarchar(150) OUTPUT
)

As
declare @selCount int
SELECT folderLocation, externalDocsID from externalDocs

set @selCount = @@ROWCOUNT
IF @@ROWCOUNT = 0
BEGIN
SET @Msgs = 'No folders meet this selection criteria'
RETURN
END
else
BEGIN
SET @Msgs = @selCount
END
return

----------------------------------------------------------------------------------

the asp code is

Dim cnnStoredProc ' Connection object
Dim cmdStoredProc ' Command object
Dim rstStoredProc ' Recordset object
Dim folderText
Set cnnStoredProc = Server.CreateObject("ADODB.Connection")
cnnStoredProc.Open db
' get the correct records for a page
Set cmdStoredProc = Server.CreateObject("ADODB.Command") ' Create Command object we'll use to execute the SP
cmdStoredProc.ActiveConnection = cnnStoredProc ' Set our Command to use our existing connection
cmdStoredProc.CommandText = "test" ' Set the SP's name and tell the Command object
cmdStoredProc.CommandType = adCmdStoredProc
cmdStoredProc.Parameters.Refresh

' ---------- SET PARAMETERS ----GET A PAGE WORTH OF RECORD--------------------------------------------------------------------
set prop=ADODB.Parameter
cmdStoredProc.Parameters("@functionCode").Value = "L" 'functionCode
cmdStoredProc.Parameters("@customerID").Value = customerId 'CustomerID
if searchCriteria <> "" then
cmdStoredProc.Parameters("@searchcriteria").Value = searchCriteria 'search string
end if
if showAssigned = "Y" then
cmdStoredProc.Parameters("@excludeDefined").Value = "Y" '
end if
set rstStoredProc = cmdStoredProc.Execute
'

response.write("msgs=" & cmdStoredProc("@Msgs")) ' <<<<<<< THIS DOESN'T WORK--------------------------------------------------------------------------------------------------

I can enumerate through the recordset but the output parameter is blank.

Any Ideas

Thanks

i believe RecordSet have a property called RecordCount...

example:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("northwind.mdb"))

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT * FROM Customers"
rs.Open sql,conn

if rs.Supports(adApproxPosition)=true then
i=rs.RecordCount
response.write("The number of records is: " & i)
end if

rs.Close
conn.Close
%>
Jul 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Marc | last post by:
Hi, I made a detailsview for inserting records. I also made a gridview for editing and deleting the same records. The keyfield is an autonumbering field in Access (pcnr). My problem is: I can...
2
by: scotdb | last post by:
I'm trying to get the SQLERRMC info from the SQLCA into my SP so that I can use the information it provides. I'm successfully getting the SQLCODE and SQLSTATE and so added the SQLERRMC to the...
5
by: noLoveLusT | last post by:
hi everyone i am very very new to the sql server (2 days actually and ) so far i learned creating SPs etc but couldnt workout how to get return value from my prodecure my sp as follows...
7
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i noticed when i run my stored procedure in sql studio i get a result set from my select statement and then below that i get a return value. how about when it's called from inside csharp....
12
by: Lennart Anderson | last post by:
I'm having a MySQl table wih a lot of information. I want to present some main fields in a table on one page. Each record do, of course, have a unique ID. The presnted table will have one field as...
1
by: John Bailo | last post by:
This is a my solution to getting an Output parameter from a SqlDataSource. I have seen a few scant articles but none of them take it all the way to a solution. Hopefully this will help some...
3
by: anammari | last post by:
I need a JAVA code / application that I can use to sort the records that exist in a Web log file. The application should take the logfile as an input and produce a sorted output file for me. For...
1
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I can successfully insert and update the oracle database by calling a oracles stored proc from my .net code. This oracle stored proc is returning some value. I cannot see that...
7
kcdoell
by: kcdoell | last post by:
Good Morning World: I have written the following code: 'Gives the user to delete and replace all records for a specified parameter LockSQL = "SELECT * FROM tblStaticAllForecast WHERE" & _...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.