Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2003, 03:12 PM
Authorized User
 
Join Date: Jun 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get output value to ASP page

Hello all

I would like to know which is the easiest way to get an output value from an SQL Server 2000 SPROC to my ASP page.

My srpoc is fairly easy: I declare a @site_id variable and at the end of the sproc I "SELECT @site_id = @@IDENTITY".

How can I easily get this @site_id value in my ASP page?

Thanks in advance

Nick
 
Old July 27th, 2003, 07:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use an output parameter from your stored procedure.

Code:
CREATE PROCEDURE MyProc
@Ret @site_id OUTPUT
AS

SELECT @site_id = @@IDENTITY
and your asp code:

Code:
Dim cmd

Set cmd = Server.CreateObject("ADODB.Command")

With cmd
    .ActiveConnection = cn
    .CommandType = adCmdStoredProc
    .CommandText = "MyProc"
    .Parameters.Append .CreateParameter("site_id", adInteger, adParamOutput)
    .Execute
End With

Response.Write cmd.Parameters("site_id").Value

Set cmd = Nothing
regards
David Cameron
 
Old July 28th, 2003, 03:04 PM
Authorized User
 
Join Date: Jun 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much. It worked fine!

Nick





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing asp output to Java topshed Java Databases 1 January 7th, 2006 10:35 AM
Output page cache question flyin General .NET 0 September 11th, 2004 04:38 PM
How-To: Programatically Set Output page caching flyin General .NET 0 September 9th, 2004 03:24 PM
passing values from ASP page to a popup ASP Page astrosmurfboy Classic ASP Basics 3 April 21st, 2004 08:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.