home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / pc / software / entwickl / win95 / pw32i306.exe / eg / foreach.pl < prev    next >
Text File  |  1997-04-09  |  590b  |  30 lines

  1. # Here is a sample that shows how to use ADO
  2. # and foreach on an OLE object
  3. #
  4. # This assumes that the AdventureWorks sample
  5. # that comes with IIS has been installed
  6.  
  7. use OLE;
  8.  
  9. $Conn = CreateObject OLE "ADODB.Connection";
  10. $Conn->Open("ADOSamples");
  11. $RS = $Conn->Execute("SELECT * FROM Orders");
  12.  
  13. $Fields = $RS->Fields;
  14. foreach $field (keys %$Fields) {
  15.     print $field->name, "\n";
  16. }
  17. print "\n";
  18.  
  19. while(!$RS->EOF) {
  20.     $Fields = $RS->Fields;
  21.     foreach $field (keys %$Fields) {
  22.         print $field->value, " ";
  23.     }
  24.     print "\n";
  25.     $RS->MoveNext;
  26. }
  27. $RS->Close;
  28. $Conn->Close;
  29.