Käynnissä

Classic ASP page to call a SQL2008 stored procedure that returns a recordset and populate an HTML table

For years we have used a block of code to store the results of a SQL select statement in a recordset in Classic ASP, then move through the recordset and built an HTML table with the data.

Now we'd like to do the same with a stored procedure using 1 integer input parameter which was originally used to augment the where clause of the select statement. The page needs to call the stored procedure with the appropriate parameter, and store the resulting recordset in the rst variable so that we can use the existing code to output the field names as headers and cycle through all records building table rows for each.

The stored procedure we're calling is below:

/****** Object: StoredProcedure [dbo].[temp2] Script Date: 02/14/2013 13:27:29 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE [dbo].[temp2]

@dr int = 33

AS

BEGIN

SET NOCOUNT ON;

select * from dept where DBCOL = @dr

SET NOCOUNT OFF;

END

Our Classic ASP code is along these lines:

'-- Create object and open database

Set objConn = [url removed, login to view]("[url removed, login to view]")

[url removed, login to view] strConn

Set objCmd = [url removed, login to view]("[url removed, login to view]")

[url removed, login to view] = objConn

dr = 1

strSQL = "select * from dept where DBCOL =" & dr

[url removed, login to view] = strSQL

set rst = [url removed, login to view]("[url removed, login to view]")

[url removed, login to view] objCmd, , 1, 1

[url removed, login to view] "" & vbcrlf

if not [url removed, login to view] and not [url removed, login to view] then

[url removed, login to view]

[url removed, login to view]

if [url removed, login to view] 0 then

for each X in [url removed, login to view]

select case [url removed, login to view]

case "fieldswedontwant"

case else

[url removed, login to view] "" & [url removed, login to view] & "" & vbcrlf

end select

next

[url removed, login to view] "" & vbcrlf

while not [url removed, login to view]

for each X in [url removed, login to view]

select case [url removed, login to view]

case "fieldswedontwant"

case else

[url removed, login to view] "" & [url removed, login to view]([url removed, login to view]).value & " " & vbcrlf

end select

next

[url removed, login to view] "" & vbcrlf

[url removed, login to view]

wend

ELSE

[url removed, login to view] "No Records Found."

end if

end if

[url removed, login to view] ""

[url removed, login to view]

set rst = nothing

Taidot: ASP, SQL

Näytä lisää: input html, html date, html command, stored, html table, eof, database html sql, call a, augment, asp sql connection, sql statement stored, table set html, html alter, recordset, variable html, html object, sql move data, populate table asp using, populate table using, html variable, sql script data set, call calling, html data sql, sql server command, script sql table

About the Employer:
( 9 reviews ) Lawrenceville, United States

Projektin tunnus: #4245255

Myönnetty käyttäjälle:

wontonesaju

hi i am providing my quote for this job. :) i am having 12 years of exp in classic asp. regards saju

50 $ USD 1 päivässä
(51 arvostelua)
5.8

3 freelanceria on tarjonnut keskimäärin 50 $ tähän työhön

expertcoder1vw

I'm an expert MS-ASP (classic) / MS-SQL Server programmer. I can code the page to output the results as per your requirements. I can complete in 3 days. Quality work, guaranteed results! Bests, Larry

70 $ USD 3 päivässä
(9 arvostelua)
4.4
nutanbhosale

we have folks with 15+ years of experience in building web pages in ASP and SQL Server. Ready to start. Thanks - Nutan

60 $ USD 2 päivässä
(6 arvostelua)
3.5
mhmsharif1

it's very easy for me ,try to help you....

40 $ USD 2 päivässä
(0 arvostelua)
0.0