Solved

Get Retrieve Dataset Rows from Stored Procedure into Classic ASP Web Page

Posted on 2013-11-11
3
611 Views
Last Modified: 2013-11-11
Greetings All,

I am doing something that is, I am sure, very simple, but I am having a hard time wrapping my head around how to do it. I have a legacy site that is in classic ASP. I am trying to call a stored procedure that will return all the rows back to the page and display them. I have to use a stored procedure (I believe) because the query uses a dynamic pivot command.

Here is the stored procedure:

SET NOCOUNT ON;
	
	declare @cmd varchar(max)
	declare @columns varchar(max)
	
	set @columns = ''

	select @columns = @columns + '['+CAST(MeetingDate AS CHAR(10))+'],' from morning_call_dates WHERE Display = 1 order by MeetingDate asc
	select @columns = substring(@columns, 0, len(@columns))

	SET @cmd = '  
		SELECT *   
		FROM vw_morning_call
		PIVOT(MAX(Entry) FOR MeetingDate IN ('+@columns+')) AS MeetingDate'  
	exec (@cmd)

Open in new window


When I execute this on the server I get a nice recordset that looks like this:

MeetingAttendee       2012-12-02        2013-12-03       2013-12-04        2013-12-05
Smith                          No                      No                     Yes                     No
Jones                           Yes                     No                     No                      Yes
Adams                         Yes                     Yes                    No                      Yes

So my questions is how do I call the procedure from classic ASP to return the data above so that I can display it on my web page. I know how to do this with a regular ADO call to the server using a query but not using a stored procedure.

Thanks in advance for your help.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 39639127
best way would be to use a command object, set your parameters (if any exist), and run it like you normally would:

                    sql = "exec sp_NameOfSP ?, ?"
                    with cmd
                        .ActiveConnection = conn
                        .CommandText = sql
                        .Parameters.Append  .CreateParameter( "param1", adInteger, adParamInput, , parameter1 )
                        .Parameters.Append  .CreateParameter( "param2", adInteger, adParamInput, , parameter2 )
                    rs.Open cmd


for more info on the command object: http://www.w3schools.com/ado/ado_ref_command.asp
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 39639131
if you have no parameters and want to do it the way you're use to, it would be very similar:

sql = "exec sp_NameOfSP"
set rs = conn.Execute( sql )
0
 
ID: 39639479
I knew it would be something pretty simple but I could have spent hours overthinking this and killing myself in the process. Thanks so much.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question