473,652 Members | 3,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting records and output parameter from ASP

1 New Member
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.CreateOb ject("ADODB.Con nection")
cnnStoredProc.O pen db
' get the correct records for a page
Set cmdStoredProc = Server.CreateOb ject("ADODB.Com mand") ' Create Command object we'll use to execute the SP
cmdStoredProc.A ctiveConnection = cnnStoredProc ' Set our Command to use our existing connection
cmdStoredProc.C ommandText = "test" ' Set the SP's name and tell the Command object
cmdStoredProc.C ommandType = adCmdStoredProc
cmdStoredProc.P arameters.Refre sh

' ---------- SET PARAMETERS ----GET A PAGE WORTH OF RECORD--------------------------------------------------------------------
set prop=ADODB.Para meter
cmdStoredProc.P arameters("@fun ctionCode").Val ue = "L" 'functionCode
cmdStoredProc.P arameters("@cus tomerID").Value = customerId 'CustomerID
if searchCriteria <> "" then
cmdStoredProc.P arameters("@sea rchcriteria").V alue = searchCriteria 'search string
end if
if showAssigned = "Y" then
cmdStoredProc.P arameters("@exc ludeDefined").V alue = "Y" '
end if
set rstStoredProc = cmdStoredProc.E xecute
'

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 5996
ck9663
2,878 Recognized Expert Specialist
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.CreateOb ject("ADODB.Con nection")
cnnStoredProc.O pen db
' get the correct records for a page
Set cmdStoredProc = Server.CreateOb ject("ADODB.Com mand") ' Create Command object we'll use to execute the SP
cmdStoredProc.A ctiveConnection = cnnStoredProc ' Set our Command to use our existing connection
cmdStoredProc.C ommandText = "test" ' Set the SP's name and tell the Command object
cmdStoredProc.C ommandType = adCmdStoredProc
cmdStoredProc.P arameters.Refre sh

' ---------- SET PARAMETERS ----GET A PAGE WORTH OF RECORD--------------------------------------------------------------------
set prop=ADODB.Para meter
cmdStoredProc.P arameters("@fun ctionCode").Val ue = "L" 'functionCode
cmdStoredProc.P arameters("@cus tomerID").Value = customerId 'CustomerID
if searchCriteria <> "" then
cmdStoredProc.P arameters("@sea rchcriteria").V alue = searchCriteria 'search string
end if
if showAssigned = "Y" then
cmdStoredProc.P arameters("@exc ludeDefined").V alue = "Y" '
end if
set rstStoredProc = cmdStoredProc.E xecute
'

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.Cre ateObject("ADOD B.Connection")
conn.Provider=" Microsoft.Jet.O LEDB.4.0"
conn.Open(Serve r.Mappath("nort hwind.mdb"))

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

if rs.Supports(adA pproxPosition)= true then
i=rs.RecordCoun t
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
1846
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 see the new inserted records in the gridview but I can't delete or edit them. When clicking on delete or edit link, nothing happens (no error either). All the others records (not inserted via the detailsview) can be edited and deleted.
2
3697
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 code which obtains these. It doesn't seem to work however - create procedure dbair001.sp001testerr ( ,OUT p_sqlstate CHAR(5) ,OUT p_sqlcode INTEGER ,OUT p_sqlerrmc VARCHAR(70)
5
2186
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 ________________________ CREATE PROCEDURE . @PageIndex INT, @PageSize INT, @Total INT OUTPUT
7
4941
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. how do i get the return value then? thanks, rodchar
12
1748
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 a linked field. I want to be able to click this link, retreive the ID information for that record and then present detailed data for that record on the next page. How do I retreive the ID? Any hints are very much appreciated. Thanks
1
12303
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 poor soul. Situation: I want to do a lookup using a stored procedure for each value in a Row within a GridView. I use a lookup function in my code behind, evaluating the necessary bound fields. The problem is the SqlDataSource representing...
3
1409
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 example to sort the records by the IP address paramemter of the records, or by the date/time parameter, or by any other parameter in the log file. Many thanks
1
1823
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 value in my .net code Below is my .net code OracleParameter mbrid = new OracleParameter("RET_MBRID", OracleType.Number); mbrid.Direction = ParameterDirection.Output;
7
8137
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" & _ " DivisionIDFK = " & Val(Me.cboDivision.Value)
0
8367
marktang
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...
1
8467
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,...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
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...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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();...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
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
2
1591
bsmnconsultancy
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...

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.