Recent

Author Topic: newbie: Simple application Fetching data from Postgress  (Read 3089 times)

bambam

  • Newbie
  • Posts: 1
newbie: Simple application Fetching data from Postgress
« on: October 11, 2007, 08:27:52 pm »
Hello I am tryiing to fetch data from one table
but I am not able to do

here is the code
can anybody help me to find issue why is Application crashing
I am flustrated find more examples about lazarus with postgres
on wikii is minimal information about PQSQL :( always MySQL :(

Code: [Select]

// Start Button on FORM

procedure TForm1.Button3Click(Sender: TObject);
begin
  // 1 columb je ID number , 2 je name of pub varchar
  TPQConnection1.UserName     := Edit3.Text;  // Imput for Usename
  TPQConnection1.Password     := Edit4.Text;   // Imput with *****
  TPQConnection1.HostName     := IPAddrEdit.Text; // PSQL IP
  TPQConnection1.DatabaseName := DBEdit.Text; // Database Name
  // On Run setting
 // TPQConnection1.Transaction  := SQLTransaction1;
  //SQLTransaction1.DataBase    := TPQConnection1;
 // SQLQuery1.DataBase          := TPQConnection1;
 // SQLQuery1.Transaction       := SQLTransaction1;
 // Check if we have an active connection. If so, let's close it.
  if  TPQConnection1.Connected then TPQConnection1.Close;
  // Set the connection parameters.
   Memo1.Append('Openning conenction');
   TPQConnection1.Open;
   Memo1.Append('done');
   
  // First lets get a list of available databases.
  if TPQConnection1.Connected then
  begin
    Memo1.Append('Yes, Connected!');
    SQLQuery1.SQL.Text := Edit1.Text;    // select pub_name from pubs;
    Memo1.Append('Setting Query');
    SQLQuery1.Open;
    Memo1.Append('Query openned!');
    while not SQLQuery1.EOF do begin
      Memo1.Append( SQLQuery1.Fields[0].AsString);
      SQLQuery1.Next;
    end;
    SQLQuery1.Close;
  end;
  SQLTransaction1.EndTransaction;
  TPQConnection1.Close;
end;                        


I need first to know how to use methods late write this result from select to file[/code]

 

TinyPortal © 2005-2018