home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 May / CMCD0505.ISO / Software / Shareware / Programare / pgedri / Source / Demos / Console / Console.dpr next >
Encoding:
Text File  |  2005-04-01  |  2.0 KB  |  63 lines

  1. {*******************************************************************}
  2. {                                                                   }
  3. {       Vita Voom Software                                          }
  4. {       Console demo                                                }
  5. {                                                                   }
  6. {       Copyright (c) 1998-2003 Vita Voom Software                  }
  7. {       ALL RIGHTS RESERVED                                         }
  8. {*******************************************************************}
  9. {                                                                   }
  10. { This project is a simple demonstration of how to make a console   }
  11. { mode application using pgExpress.                                 }
  12. {                                                                   }
  13. { Please refer to the Readme.txt file for details.                  }
  14. {                                                                   }
  15.  
  16. program Console;
  17.  
  18. {$APPTYPE CONSOLE}
  19.  
  20. uses
  21.   SysUtils,
  22.   SqlExpr;
  23.  
  24. var
  25.   Conn: TSQLConnection;
  26.   Dataset: TSQLDataset;
  27.   Count: Integer;
  28. begin
  29.   WriteLn('Starting pgExpress console demo...');
  30.   WriteLn;
  31.   Conn := nil;
  32.   Dataset := nil;
  33.   Count := 0;
  34.   try
  35.     Conn := TSQLConnection.Create(nil);
  36.     Conn.LoadParamsOnConnect := True;
  37.     Conn.ConnectionName := 'PGEConnection';
  38.     // Set your password below if needed
  39.     //Conn.Params.Add('Password=xxxx')
  40.     Dataset := TSQLDataset.Create(Conn);
  41.     with Dataset do
  42.     begin
  43.       SQLConnection := Conn;
  44.       CommandType := ctQuery;
  45.       CommandText := 'select * from pg_type where typtype=''b''';
  46.       Open;
  47.       if not Eof then
  48.         WriteLn('Types registered in you server:');
  49.       while not Eof do
  50.       begin
  51.         WriteLn(Dataset.FieldByName('typname').AsString);
  52.         Next;
  53.         Inc(Count);
  54.       end;
  55.       WriteLn;
  56.       WriteLn('Total: ', Count, ' record(s).'); 
  57.     end;
  58.   finally
  59.     Dataset.Free;
  60.     Conn.Free;
  61.   end;
  62. end.
  63.