home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / StoredProcedures_VBScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  1.8 KB  |  72 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.     ' To run this sample, you must first do the following:
  11.     '
  12.     '            1) Go to the System Control Panel
  13.     '            2) Open the OBDC Control Panel 
  14.     '            3) Select the System DSN Tab and Add a Source
  15.     '            4) Choose the SQL Server Driver and hit Finish
  16.     '            5) Name the Source "IISSDK", enter the name of the local server
  17.     '            6) Setup Security (Note: If you have setup a password on the
  18.     '               SQL Server, you may have to change the example below)
  19.     '            7) Set the Default Database to the pubs db that comes with SQL
  20. %>
  21.  
  22.  
  23. <HTML>
  24.     <HEAD>
  25.         <TITLE>Using Stored Procedures</TITLE>
  26.     </HEAD>
  27.  
  28.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  29.         
  30.         <!-- Display Header -->
  31.  
  32.         <font size="4" face="Arial, Helvetica">
  33.         <b>Using Stored Procedures</b></font><p>   
  34.  
  35.         <%
  36.             Dim oConn        
  37.             Dim oCmd    
  38.             Dim oRs        
  39.  
  40.             Set oConn = Server.CreateObject("ADODB.Connection")
  41.             Set oCmd = Server.CreateObject("ADODB.Command")
  42.  
  43.             
  44.             ' Open ADO Connection using account "sa"
  45.             ' and blank password
  46.  
  47.             oConn.Open "IISSDK", "sa", ""
  48.             Set oCmd.ActiveConnection = oConn
  49.  
  50.  
  51.             ' Setup Call to Stored Procedure and append parameters
  52.  
  53.             oCmd.CommandText = "{call byroyalty(?)}"
  54.             oCmd.Parameters.Append oCmd.CreateParameter("@Percentage", adInteger, adParamInput)
  55.  
  56.             
  57.             ' Assign value to input parameter
  58.  
  59.             oCmd("@Percentage") = 75
  60.  
  61.  
  62.             ' Fire the Stored Proc and assign resulting recordset
  63.             ' to our previously created object variable
  64.                     
  65.             Set oRs = oCmd.Execute            
  66.         %>
  67.  
  68.         Author ID = <% Response.Write oRs("au_id") %><BR>
  69.  
  70.     </BODY>
  71. </HTML>
  72.