.NETJiNi@jigneshdesai.com  
  Home |  .NET<1.0 to 3.5> Forums Blogs |  Other Technologies Skip Navigation Links  | Quiz Contest   dotnetJini Training |   Software Development 
   
Topic : STORED PROCEDURE: Returning Recordsets
Author : Jignesh Total Visits: 196
Published Date: Monday, October 09, 2000  

The following SQL stored procedure returns a set of rows from the employee table where the salary is less than the value passed :

CREATE PROCEDURE empsal 
(
@limit INT
)
AS
SELECT * From employee WHERE salary < @limit

To execute this stored procedure, you can use the following Active Server Pages script:

<!-- #INCLUDE FILE="adovbs.inc" -->  
<% 
Set Con = Server.CreateObject( "ADODB.Connection" ) 
Con.Open "Provider=SQLOLEDB;UID=jignesh;PWD=friends" 

Set myCommand = Server.CreateObject( "ADODB.Command" ) 
myCommand.ActiveConnection = Con 
MyCommand.CommandType = adCmdStoredProc 
MyCommand.CommandText = "empsal" 

MyCommand.Parameters.Append MyCommand.CreateParameter( "returnCode", adInteger, adParamReturnValue ) 

MyCommand.Parameters.Append MyCommand.CreateParameter( "limit", adInteger, adParamInput ) 

MyCommand( "limit" ) = 5700 
Set RS = MyCommand.Execute 

' Display Recordset 
While NOT RS.EOF 
Response.Write RS( 0 ) & " - " & RS( 1 ) & "<br>" 
RS.MoveNext 
WEND %>









 
   
   
   
Add URL | About ME Privacy Policy | Legal Disclaimer

Copyright (C) 2004 -2008 JigneshDesai.com. All rights reserved