Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 February 24th, 2005, 05:06 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using recordsets in Stored Procedures

Is it possible to use a stored procedure to return values to a web page and insert them into the appropriate fields like it is possible with VB?
 
Old February 24th, 2005, 06:56 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

yes, it is very much possible...

Om Prakash
 
Old February 25th, 2005, 10:18 AM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How would I go about doing such a thing?

Max
 
Old February 25th, 2005, 11:38 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have not tested this but this will give you general idea
ASP Code Begin
<%

Dim objCmd, objRs, objParam1

' Create an instance of the Command object
Set objCmd = Server.CreateObject("ADODB.Command")

Dim objConn
Set ObjConn = Server.CreateObject("ADODB.Connection")
ObjConn.Open strConnect 'strConnect is your connection string


objCmd.CommandText = "get_Values"

' Set the command Type to the adCmdStoredProc enum value
objCmd.CommandType = adCmdStoredProc

' Create the Parameters

Set objParam1 = objCmd.CreateParameter("@ID", int, adParamInput)
objParam1.Value = 1 ' Your ID value


' Append the Parameters to the Command Object
objCmd.Parameters.Append(objParam1)

' Set the Connection of the Command Object
objCmd.ActiveConnection = objConn

' Execute the Command
Set objRs = objCmd.Execute()

Dim frmField1 = objRs("field1)
Dim frmField2 = ObjRs("field2")

' Clean-up
ObjRs.Close
Set objRs = Nothing
Set objCmd = Nothing
ObjConn.Close
Set ObjConn = Nothing

%>

<HTML>
<head>
</head>
<body>
<table width="100%" >
<tr>
<td>Form Field1</td>
<td><input type="text" name="frmField1" value="<%=frmField1%>">&nbsp;</td>
</tr>
<tr>
<td>Form Field2</td>
<td><input type="text" name="frmField2" value="<%=frmField2%>">&nbsp;</td>
</tr>
</table>
</body>
</HTML>

ASP Code End

--SQL Server Stored Procedure
CREATE PRoCEDURE get_VALUES
@ID int
AS
BEGIN
SELECT field1,field2
FROM MyTable
WHERE ID = @ID
END





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedures umeshtheone SQL Server 2000 0 June 19th, 2007 01:08 AM
stored procedures thillaiarasu ASP.NET 2.0 Basics 2 May 3rd, 2007 07:55 AM
Recordsets and Stored Procedures Roy0 Access VBA 17 March 14th, 2007 04:32 AM
Return 2 Recordsets from 1 Stored Proc Gordie Classic ASP Databases 0 July 3rd, 2006 05:34 PM
RecordSets vs Stored Procedures in Access Roy0 SQL Language 0 December 28th, 2005 02:02 PM





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