Hi all,
I am now on the stage of using Lazarus mainly for my database centric applications(previously VB.Net). I read somewhere in this forum that the best way to program a client/server app is to separate the UI and the business logic into two separate modules. But I have no way in my current capacity to do this. So I used Lazarus mainly for UI and SQL queries. This will work for me for the time being.
I am using these DB controls: SQLQuery, Datasource, SQLTransaction, PQConnection to connect to PostgreSQL and TDBGrid for viewing.
My question is, what would be the best method/ways/techniques to use these controls?
I mean, I have this error lately: Access Violation, when I tried to use the above tools, use the SQLQuery1.SQL ='myquery' during runtime works fine, but when I try to use the SQLQuery1.AfterScroll event to capture data from TDBGrid, it will generate Access Violation Error.
The nature of my application is to connect to PostgreSQL, perform database queries,inserts, etc., and create reports.
In my insert and query(eg. querying for ID) I used the DB tools and create them during runtime by:
procedure InitializeDB();
begin
INK_DB := TPQConnection.Create(nil);
INK_SQL := TSQLQuery.Create(nil);
INK_TRANSACTION := TSQLTransaction.Create(nil);
INK_DATASOURCE := TDatasource.Create(nil);
if not INK_DB.Connected then
begin
INK_DB.HostName := DATABASE_HOST;
INK_DB.DatabaseName := DATABASE_NAME;
INK_DB.UserName := DATABASE_USER;
INK_DB.Password := DATABASE_PASSWORD;
INK_DB.Connected := True;
end;
end;
Then free them after every use:
procedure FreeDB();
begin
INK_SQL.Close;
INK_DB.Close;
INK_TRANSACTION.Active := False;
INK_DB.Free;
INK_TRANSACTION.Free;
INK_SQL.Free;
end;
In other words, I just want to solicit advices and ideas on how to design my application using Lazarus with the mentioned DB tools that can point me to resources and help me avoid complexities in the future before going deep with Lazarus.
Regards,
Allan