testbcon.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. program testbcon;
  2. {
  3. Test browsingconnection
  4. - I don't have a driver which supports it though :/
  5. }
  6. {$mode objfpc}
  7. uses fpodbc,Classes;
  8. Type
  9. TApp = Class (TObject)
  10. Conn : TODBCConnection;
  11. Procedure GetParams (Sender : TObject; ListIn,ListOut : TStrings);
  12. Procedure Run;
  13. end;
  14. { TApp }
  15. procedure TApp.GetParams(Sender: TObject; ListIn, ListOut: TStrings);
  16. Var
  17. S : String;
  18. i : integer;
  19. begin
  20. Writeln('Input parameters were :');
  21. With ListIN do
  22. For I:=0 to Count-1 do
  23. Writeln(Strings[i]);
  24. Writeln('Output parameters were :');
  25. With Listout do
  26. For I:=0 to Count-1 do
  27. Writeln(Strings[i]);
  28. Repeat
  29. Writeln('Parameter to add to input (empty to quit):');
  30. Readln(S);
  31. If S<>'' then
  32. ListIn.Add(S)
  33. Until S='';
  34. end;
  35. procedure TApp.Run;
  36. begin
  37. Conn:=TODBCConnection.Create(Nil);
  38. Try
  39. Conn.DSN:='FPC';
  40. Conn.OnBrowseConnection:[email protected];
  41. Conn.Active:=True;
  42. Writeln('Connected !!');
  43. Conn.Active:=False;
  44. Finally
  45. Conn.free;
  46. end;
  47. end;
  48. begin
  49. With Tapp.Create do
  50. Try
  51. Run;
  52. Finally
  53. Free;
  54. end;
  55. end.