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.

66 lines
2.1 KiB

  1. <%@ LANGUAGE = PerlScript%>
  2. <html>
  3. <head>
  4. <meta name="GENERATOR" content="Tobias Martinsson">
  5. <title>ADO Error Checking</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) Errors</H3>
  20. Whenever an error during the database session occurs, the Errors collection of the Connection object is where you need to go. It contains a group of Error objects that you can examine in order to understand the error. However, this is not the same as detecting an error -- although closely related. The "count"-property of the Errors collection returns the number of Error objects present, thus you use it best to detect errors.
  21. <p>
  22. <%
  23. # Create an instance of a Connection object
  24. #
  25. $conn = $Server->CreateObject("ADODB.Connection");
  26. # Open it by providing a System DSN as the parameter
  27. #
  28. $conn->Open( "ADOSamples" );
  29. # Deliberately cause an error by typo'ing the query
  30. #
  31. $conn->Execute( "ZELKECT * FROM Orders" );
  32. if($conn->Errors->{Count} > 0) {
  33. $Response->Write("There's been an error ...");
  34. $Response->Write($conn->Errors(0));
  35. }
  36. $conn->Close(); # Close the connection
  37. undef($conn); # Destroy the object
  38. %>
  39. <!-- +++++++++++++++++++++++++++++++++++++
  40. here is the standard showsource link -
  41. Note that PerlScript must be the default language --> <hr>
  42. <%
  43. $url = $Request->ServerVariables('PATH_INFO')->item;
  44. $_ = $Request->ServerVariables('PATH_TRANSLATED')->item;
  45. s/[\/\\](\w*\.asp\Z)//m;
  46. $params = 'filename='."$1".'&URL='."$url";
  47. $params =~ s#([^a-zA-Z0-9&_.:%/-\\]{1})#uc '%' . unpack('H2', $1)#eg;
  48. %>
  49. <A HREF="index.htm"> Return </A>
  50. <A HREF="showsource.asp?<%=$params%>">
  51. <h4><i>view the source</i></h4></A>
  52. </BODY>
  53. </HTML>