home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _46cad438898feab3f790e5a47789b8bb < prev    next >
Text File  |  2004-06-01  |  2KB  |  74 lines

  1. <%@ LANGUAGE = PerlScript%>
  2. <html>
  3. <head>
  4. <meta name="GENERATOR" content="Tobias Martinsson">
  5.  
  6. <title>ADO Stored Procedures That Return Values</title>
  7. </head>
  8. <body>
  9. <BODY BGCOLOR=#FFFFFF>
  10.  
  11. <!-- 
  12.     ActiveState PerlScript sample 
  13.     PerlScript:  The coolest way to program custom web solutions. 
  14. -->
  15.  
  16. <!-- Masthead -->
  17. <TABLE CELLPADDING=3 BORDER=0 CELLSPACING=0>
  18. <TR VALIGN=TOP ><TD WIDTH=400>
  19. <A NAME="TOP"><IMG SRC="PSBWlogo.gif" WIDTH=400 HEIGHT=48 ALT="ActiveState PerlScript" BORDER=0></A><P>
  20. </TD></TR></TABLE>
  21.  
  22. <HR>
  23.  
  24. <H3>ActiveX Data Objects (ADO) Stored Procedures That Return Values</H3>
  25. Returning values from a stored procedure. The procedure looks as follows:
  26. <pre>
  27. CREATE PROC Test 
  28. AS
  29. RETURN(64)
  30. </PRE>
  31. <BR>
  32. <BR>
  33. <B>Output from stored procedure:</B><BR>
  34. <%
  35.  
  36. $cmd = $Server->CreateObject('ADODB.Command');
  37. $conn = $Server->CreateObject('ADODB.Connection');
  38.  
  39. $conn->Open(<<EOF);
  40.                          Provider=SQLOLEDB;
  41.                          Persist Security Info=False;
  42.                          User ID=sa;
  43.                          Initial Catalog=Northwind;
  44. EOF
  45.  
  46. $cmd->{ActiveConnection} = $conn;
  47. $cmd->{CommandText} = 'Test'; # Name of stored procedure
  48. $cmd->{CommandType} = 4; # Says it will return a value
  49.  
  50. $cmd->Parameters->Append( $cmd->CreateParameter('RetVal', 2, 4) );
  51.  
  52. $cmd->Execute(); # Execute the stored procedure
  53.  
  54. print $cmd->Parameters('RetVal')->{Value}; 
  55.  
  56. $conn->Close();
  57. undef($conn);
  58. undef($cmd);
  59.  
  60. %>
  61.  
  62. <%
  63.     $url = $Request->ServerVariables('PATH_INFO')->item;
  64.     $_ = $Request->ServerVariables('PATH_TRANSLATED')->item;
  65.     s/[\/\\](\w*\.asp\Z)//m;
  66.     $params = 'filename='."$1".'&URL='."$url";
  67.     $params =~ s#([^a-zA-Z0-9&_.:%/-\\]{1})#uc '%' . unpack('H2', $1)#eg;
  68. %>
  69. <BR><BR>
  70. <A HREF="index.htm"> Return </A>
  71. <A HREF="showsource.asp?<%=$params%>">
  72. <h4><i>view the source</i></h4></A>  
  73. </BODY>
  74. </HTML>