123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- { $Id$
-
- Copyright (c) 2000 by Pavel Stingl
- Interbase testing program
-
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- program TestIB;
- {$linklib dl}
- {$linklib crypt}
- uses Interbase, SysUtils;
- var
- Database : TIBDatabase;
- Trans : TIBTransaction;
- Query : TIBQuery;
- x : integer;
- begin
- Database := TIBDatabase.Create(nil);
- Trans := TIBTransaction.Create(nil);
- Query := TIBQuery.Create(nil);
-
- Database.DatabaseName := 'test.gdb';
- Database.UserName := 'sysdba';
- Database.Password := 'masterkey';
- Database.Transaction := Trans;
- Trans.Action := caRollback;
- Trans.Active := True;
-
-
- Write('Opening database... Database.Connected = ');
- Database.Open;
- WriteLn(Database.Connected);
-
- // Assigning database to dataset
- Query.Database := Database;
-
- Query.SQL.Add('select * from fpdev');
- Query.Open;
-
- WriteLn;
-
- while not Query.EOF do
- begin
- for x := 0 to Query.FieldCount - 2 do
- Write(Query.Fields[x].AsString,',');
- WriteLn(Query.Fields[Query.FieldCount - 1].AsString);
- Query.Next;
- end;
-
- WriteLn;
-
-
- try
- WriteLn('Trying to insert new record to table fpdev');
- Query.Close;
- Query.SQL.Clear;
- Query.SQL.Add('insert into fpdev values (''9'',''John Doe'',''[email protected]'')');
- Query.ExecSQL;
- Trans.CommitRetaining;
- WriteLn('Insert succeeded.');
- except
- on E:Exception do
- begin
- WriteLn(E.Message);
- WriteLn('Error when inserting record. Transaction rollback.');
- Trans.RollbackRetaining;
- end;
- end;
-
- WriteLn;
-
- Trans.Commit;
-
- Write('Closing database... Database.Connected = ');
- Database.Close;
- WriteLn(Database.Connected);
- end.
- {
- $Log$
- Revision 1.3 2000-12-02 15:21:47 michael
- + Merged from the fixbranch
- Revision 1.2 2000/07/13 11:32:57 michael
- + removed logs
-
- }
|