Use stored procedure to return results and total

Using classic ASP/MS SQL 2008

I am trying to create a simple stored procedure for reports. I want it to return the results so that I can display them on a table, this is what I did, but nothing is returned  :#

I need to results to be returned along with the total of records as well.

/****** Object:  StoredProcedure [dbo].[rp_contacts_01_results]    Script Date: 03/23/2015 09:46:03 ******/


CREATE PROCEDURE [dbo].[rp_contacts_01_results]
    SELECT  a.UserId ,
            a.FirmId ,
            a.EmployerId ,
            a.LastNm ,
            a.FirstNm ,
            a.Title ,
            a.Email ,
    FROM    Users a
            LEFT JOIN Users AS b ON a.EmployerId = b.UserId
    WHERE   a.UserType = 'corpuser'
    ORDER BY b.MaidenNm ,

I am using Dreamweaver to run the command, but none of the results are showing up. It only works if I do a recordset with a query on the page in which case I cant use a stored procedure  :(
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AleksAuthor Commented:
This is what I did:

but when I expand the stored procedure it only shows @RETURN_Value instead of each of the fields I selected along with the total just like a recordset would do.
Big MontyWeb Ninja at largeCommented:
It only works if I do a recordset with a query on the page in which case I cant use a stored procedure  :(

that's not necessarily true, you can call a stored procedure and stick the results into a recordset. I'm not going to refer to the above URL as it doesn't really show you what you need to do. I would refer here for a better explanation on how to do what you're looking

in the meantime, you can use the following code as a base to build what you want:

        set rs = Server.CreateObject("ADODB.RecordSet")
        set conn = Server.CreateObject("ADODB.Connection")
        set cmd = Server.CreateObject("ADODB.Command")

        sql = "rp_contacts_01_results"
        conn.Open connectionString

        with cmd
            .ActiveConnection = conn
            .CommandText = sql
     '--       .Parameters.Append  .CreateParameter( "paramName", adVarChar, adParamInput, 15, paramValue )
        end with
        rs.Open cmd

        if not rs.BOF and rs.EOF then    '-- results were returned
             do while not rs.EOF
                '-- write out your results however you like
        end if

       '-- clean up
       if rs.State <> 0 then rs.Close
       set rs = nothing
       if conn.State <> 0 then conn.Close
       set conn = nothing
       set cmd = nothing

Open in new window

you'll see in the command definition, I commented out a parameter. I left that as an example in case you wanted to eventually pass in a parameter(s). If you don't need it, you can safely remove that line
AleksAuthor Commented:
Problem is I don't think Dreamweaver will recognize that recordset and therefore I won't be able to use the interface to display the results, etc. Which is something I would like to keep doing.
Big MontyWeb Ninja at largeCommented:
you should still be able to insert the code into your page and have it run correctly. Dreamweaver is getting pretty outdated, I would recommend maybe looking into using new tricks and techniques

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Yep, thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.