home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / StoredProcedures_JScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  1.8 KB  |  71 lines

  1. <%     @ LANGUAGE="JScript"         %>
  2.  
  3. <!--#include file="adojavas.inc"-->
  4.  
  5. <%
  6.     // This example calls the ByRoyalty stored procedure 
  7.     // installed with the PUBS database with Microsoft SQL Server.
  8.  
  9.     // To run this sample, you must first do the following:
  10.     //
  11.     //            1) Go to the System Control Panel
  12.     //            2) Open the OBDC Control Panel 
  13.     //            3) Select the System DSN Tab and Add a Source
  14.     //            4) Choose the SQL Server Driver and hit Finish
  15.     //            5) Name Source "IISSDK", enter name of the local server
  16.     //            6) Setup Security (Note: If you have setup a password on the
  17.     //               SQL Server, you may have to change the example below)
  18.     //            7) Set Default Database to the pubs db that comes with SQL
  19. %>
  20.  
  21.  
  22. <HTML>
  23.     <HEAD>
  24.         <TITLE>Using Stored Procedures</TITLE>
  25.     </HEAD>
  26.  
  27.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  28.         
  29.         <!-- Display Header -->
  30.  
  31.         <font size="4" face="Arial, Helvetica">
  32.         <b>Using Stored Procedures</b></font><p>   
  33.  
  34.         <%
  35.             var oConn;        
  36.             var oCmd;        
  37.             var oRs;    
  38.  
  39.             oConn = Server.CreateObject("ADODB.Connection");
  40.             oCmd = Server.CreateObject("ADODB.Command");
  41.  
  42.             
  43.             // Open ADO Connection using account "sa"
  44.             // and blank password
  45.  
  46.             oConn.Open("IISSDK", "sa", "");
  47.             oCmd.ActiveConnection = oConn;
  48.  
  49.  
  50.             // Setup Call to Stored Procedure and append parameters
  51.  
  52.             oCmd.CommandText = "{call byroyalty(?)}";
  53.             oCmd.Parameters.Append(oCmd.CreateParameter("@Percentage", adInteger, adParamInput));
  54.  
  55.  
  56.             // Assign value to input parameter
  57.     
  58.             oCmd("@Percentage") = 75;        
  59.             
  60.             
  61.             // Fire the Stored Proc and assign resulting recordset
  62.             // to our previously created object variable
  63.             
  64.             oRs = oCmd.Execute();            
  65.         %>
  66.  
  67.         Author ID = <% Response.Write(oRs("au_id")) %><BR>
  68.  
  69.     </BODY>
  70. </HTML>
  71.