Change ProtocolVersion at run-time

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
PaulReeves
Posts: 4
Joined: Fri 05 Aug 2011 13:32
Location: United States

Change ProtocolVersion at run-time

Post by PaulReeves » Fri 05 Aug 2011 13:40

Is it possible to change the protocolversion at runtime? pv30 is 3x slower for my connection, but it provides better feedback. I'd like to give the user the option to switch protocols. Seems simple, but I haven't figured it out ...

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 05 Aug 2011 14:45

Hello,

You can use the following code to change the protocol version in the runtime:

Code: Select all

procedure TForm1.ChangeProtocol(Connection: TPgConnection;
  Value: TProtocolVersion);
var
  OldState: Boolean;
begin
  if not Assigned(Connection) then exit;
  if Value  Connection.ProtocolVersion then
  begin
    if Connection.Connected then
    begin
      OldState := true;
      Connection.Disconnect;
    end;
    Connection.ProtocolVersion := Value;
    if OldState then
      Connection.Connect;
  end;
end;

Post Reply