home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / StoredProcedures_VBScript.asp < prev    next >
Text File  |  1997-10-25  |  1KB  |  63 lines

  1. <%     @ LANGUAGE="VBSCRIPT"         %>
  2. <%    Option Explicit                %>
  3.  
  4. <!--#include file="adovbs.inc"-->
  5.  
  6. <%
  7.     ' This example can be used to call the ByRoyalty stored procedure 
  8.     ' installed with the PUBS database with Microsoft SQL Server.
  9.  
  10.     ' This sample assumes that SQL Server is running on the local machine
  11. %>
  12.  
  13.  
  14. <HTML>
  15.     <HEAD>
  16.         <TITLE>Using Stored Procedures</TITLE>
  17.     </HEAD>
  18.  
  19.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  20.         
  21.         <!-- Display Header -->
  22.  
  23.         <font size="4" face="Arial, Helvetica">
  24.         <b>Using Stored Procedures</b></font><p>   
  25.  
  26.         <%
  27.             Dim oConn        
  28.             Dim oCmd    
  29.             Dim oRs        
  30.  
  31.             Set oConn = Server.CreateObject("ADODB.Connection")
  32.             Set oCmd = Server.CreateObject("ADODB.Command")
  33.  
  34.             
  35.             ' Open ADO Connection using account "sa"
  36.             ' and blank password
  37.  
  38.             oConn.Open "DSN=LocalServer;UID=sa;PWD=;DATABASE=pubs"
  39.             Set oCmd.ActiveConnection = oConn
  40.  
  41.  
  42.             ' Setup Call to Stored Procedure and append parameters
  43.  
  44.             oCmd.CommandText = "{call byroyalty(?)}"
  45.             oCmd.Parameters.Append oCmd.CreateParameter("@Percentage", adInteger, adParamInput)
  46.  
  47.             
  48.             ' Assign value to input parameter
  49.  
  50.             oCmd("@Percentage") = 75
  51.  
  52.  
  53.             ' Fire the Stored Proc and assign resulting recordset
  54.             ' to our previously created object variable
  55.                     
  56.             Set oRs = oCmd.Execute            
  57.         %>
  58.  
  59.         Author ID = <% Response.Write oRs("au_id") %><BR>
  60.  
  61.     </BODY>
  62. </HTML>
  63.