Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.9 KiB

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