What I am attempting to do is re-use a TPQConnection with each form. I'm
thinking that it is best to have only one connection open to the database
engine (postgres). I placed the TPQConnection in a datamodule. Below is
some code from my login form:
procedure TForm3.Button1Click(Sender: TObject);
begin
data3.DataModule1.PQConnection1.UserName:=self.Edit1.Text;
data3.DataModule1.PQConnection1.password:=self.edit2.text;
data3.DataModule1.PQConnection1.HostName:=self.Edit3.text;
data3.DataModule1.PQConnection1.databasename:='Real-Accounting';
try
data3.DataModule1.PQConnection1.Open;
self.Close;
except
showmessage('Sorry could not connect to the database');
self.close;
end;
end;
This makes a connection. At least I think so! I also set the
keepconnection:=true. So I think the connection is open.
Now in another form (unit2.pas) I added a TSQLTransaction and TSQLQuery. I
want to set the properties of DB objects dynamically. So I then attempt the
following:
procedure TForm2.FormCreate(Sender: TObject);
begin
self.SQLTransaction1.DataBase:= data3.DataModule1.PQConnection1;
try
self.DataSource1.DataSet := SQLQuery1;
SQLQuery1.SQL.Text := 'Select * from arcust';
SQLQuery1.Open;
finally
SQLQuery1.Close;
end;
end;
But the 'SQLQuery1.Open' fails.
Error: database not assigned.
What am I doing wrong?
John
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives