cfilltable.pp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. (******************************************************************************
  2. * *
  3. * (c) 2005 CNOC v.o.f. *
  4. * *
  5. * File: cFillTable.pp *
  6. * Author: Joost van der Sluis ([email protected]) *
  7. * Description: SQLDB example and test program *
  8. * License: GPL *
  9. * *
  10. ******************************************************************************)
  11. program CFillTable;
  12. {$mode objfpc}{$H+}
  13. uses
  14. Classes,
  15. sqldb,
  16. SqldbExampleUnit;
  17. begin
  18. ReadIniFile;
  19. CreateFConnection;
  20. CreateFTransaction;
  21. // create FQuery
  22. Fquery := TSQLQuery.create(nil);
  23. with Fquery do
  24. begin
  25. database := Fconnection;
  26. transaction := Ftransaction;
  27. end;
  28. with Fquery do
  29. begin
  30. SQL.Clear;
  31. SQL.Add('insert into FPDEV ( ');
  32. SQL.Add(' id, ');
  33. SQL.Add(' Name, ');
  34. SQL.Add(' Email, ');
  35. SQL.Add(' Birthdate) ');
  36. SQL.Add('values ( ');
  37. SQL.Add(' 1, ');
  38. SQL.Add(' ''Florian Klaempfl'', ');
  39. SQL.Add(' ''[email protected]'',');
  40. // Please update the date format according to your database (ie. MySQL 1975-1-1)
  41. SQL.Add(' ''1-jan-1975'' ');
  42. SQL.Add(') ');
  43. ExecSql;
  44. end;
  45. Ftransaction.CommitRetaining;
  46. Fquery.Free;
  47. Ftransaction.Free;
  48. Fconnection.Free;
  49. end.