Page 1 of 1

Delphi + ADO + PostgreSQL

Posted: 06.10.2010, 12:51
by Marcin W.
1. On computer an ODBC driver for Postgres is installed and configured properly

2. I choose in ZConnection Protocol: ADO and Provider: MSDASQL.1;Persist Security Info=False;Data Source=PostgreSQL

3. IP address of Postgres is set in ODBC

4. If I choose IP of my local PC and try to open Query - it's OK, but if I choose remote host and try open Query, got an error "nieokreślony błąd" (unknown/undefined error)

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  i : integer;
begin
  ZConnection1.User     := LabeledEdit1.Text;
  ZConnection1.Password := LabeledEdit2.Text;

  try
    ZConnection1.Connect;
  except
    on E : Exception do
        begin
          ShowMessage('error connecing: ' + E.Message);
        end;
  end;

  if (ZReadOnlyQuery1.Active) then
    ZReadOnlyQuery1.Active := false;

  ZReadOnlyQuery1.SQL.Clear;
  ZReadOnlyQuery1.SQL.Add('select * from ankieta_zestaw where widoczne = :p_widoczne;');

  ZReadOnlyQuery1.Params.Clear;
  ZReadOnlyQuery1.Params.CreateParam(ftInteger, 'p_widoczne', ptInput);
  ZReadOnlyQuery1.ParamByName('p_widoczne').AsInteger := 1;

  try
    ZReadOnlyQuery1.Open;
  except
    on E : Exception do
        begin
          ShowMessage('error opening: ' + E.Message);
        end;
  end;

end;

Posted: 06.10.2010, 18:38
by mrLion
Marcin W., why use ADO? use direct access "postgresql" - protocol. ADO - is bad idea.

Posted: 06.10.2010, 19:02
by Marcin W.
I know, that it is a bad idea, but I have to.

Posted: 08.10.2010, 17:45
by mrLion
Marcin W., can`t understand ..... why? Simple change one property to postgresql and that`s all....