Page 1 of 1

Change ProtocolVersion at run-time

Posted: Fri 05 Aug 2011 13:40
by PaulReeves
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 ...

Posted: Fri 05 Aug 2011 14:45
by AlexP
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;