Stored Procedure and ASP.. How do I get the values and execute correctly. I need help (easy question, but urgent)
Posted on 2004-09-17
I am trying to write a stored procedure that executes several select statements and returns the values (all integers). I am starting with only 3 selects, but after I get it working correctly it will contain more queries. The SP runs fine in the analyzer and I think I have it set up correctly. (I usually do all of my queries and selects in the ASP code.).
I dont know how I need to execute the procedure from ASP as well as how I get the values it returns. I have read several articles and questions posted here and I have tried several different ways, but I can not seem to get the values.
Also, I want to make sure I am going down the correct path. This Procedure will end up being incorporated into a loop in my ASP code which cycles through the database selecting various groups and returning the totals which I will output to the screen. Wouldnt it be the best to have this in a SP? I dont want to waste all of this time because I could have built the thing in ASP twice already. This application will have several users at a time hitting it and I want to make it the most efficient.
My SP is as follows:
CREATE PROCEDURE Get_Totals_Branch
@Total_Records int = Null OUTPUT,
@Total_Units int = Null OUTPUT,
@Risk_Contracts int = NULL OUTPUT
SELECT @Total_Records = COUNT(*)FROM fisTkextend where branch = @branch
SELECT @Total_Units = SUM(NumUnits)FROM fisTkextend where branch = @branch
SELECT @Risk_Contracts = count(*) from fisTKExtend where Expire_Date <= getdate() + 451 and branch = @branch
Like I said. I dont know the easiest or most efficient way to get the data from the SP in ASP. I have tried several different ways, but I am sure you guys can tell me how to do it. Thank you in advance. My deadline is quickly approaching and the frying pan is getting hot.