Page 1 of 1

Bug if don't activate main form

Posted: 31.08.2009, 15:20
by hugleo

Code: Select all

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {DataModule2: TDataModule};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TDataModule2, DataModule2);

  DataModule2.QueryPesq.SQL.Clear;
  DataModule2.QueryPesq.SQL.Append('select * from my_table');
  DataModule2.QueryPesq.Open;

  //Application.Run;
end. 
I need to do a search Zeos before starting the main form ... (Application.Run;). I just perform my research Application.Run to return a result. The query executes successfully, but if I do not run Application.Run (which is what I want), the Zeos causes an exception .. Application.Terminate I've tried, but did not work.

The following code works:

-> Query_do_Zeos;
Application.Run;

But the following does not work (cause exception error in ZDbcMySqlResultSet.pas):
-> Query_do_Zeos;
/ / Application.Run;

Can anyone help?

Posted: 31.08.2009, 16:26
by gto
- Have you connected to the database?
cause exception error in ZDbcMySqlResultSet.pas
- Can you send the entire error message, or a print screen ?

- If you want to avoid the error, use a try..except construction.

I do have a program which connect, run queries and LOTS of things before the Application.Run. And even without calling Application.Run along the app run (Console APP and Service APP).

Posted: 31.08.2009, 16:56
by hugleo
gto wrote:- Have you connected to the database?
cause exception error in ZDbcMySqlResultSet.pas
- Can you send the entire error message, or a print screen ?

- If you want to avoid the error, use a try..except construction.

I do have a program which connect, run queries and LOTS of things before the Application.Run. And even without calling Application.Run along the app run (Console APP and Service APP).
Follow the printscreen:
http://img142.imageshack.us/img142/1962/zeos.jpg

Follow to the link to my full application:
http://rapidshare.com/files/273897608/test.zip.html

That error occurs for any database that I've tested. My Delphi version is 7.0.
This error happens if I use the zeos and not need Application.Run.
I think the zeos requires Application.Run to do something.

Posted: 31.08.2009, 20:07
by gto
Try with this source in your project file:

Code: Select all

program Project1;

uses
   Windows,
   Forms,
   Unit1 in 'Unit1.pas' {Form1},
   Unit2 in 'Unit2.pas' {DataModule2: TDataModule};

{$R *.res}

begin
   Application.Initialize;
   Application.CreateForm(TForm1, Form1);
   Application.CreateForm(TDataModule2, DataModule2);

   DataModule2.Conexao.Connect;

   DataModule2.QryPesq.SQL.Clear;
   DataModule2.QryPesq.SQL.Append('select * from mytable');
   DataModule2.QryPesq.Open;

   if DataModule2.QryPesq.IsEmpty then
      Windows.Messagebox(0, PChar('query empty!'), '', MB_OK)
   else
      Windows.Messagebox(0, PChar(DataModule2.QryPesq.FieldByName('code').AsString), '', MB_OK);

   DataModule2.QryPesq.Close;
   DataModule2.Conexao.Disconnect;
end.
I think you missed the connecting statedment, or even close the query. Anyway, I got the same error when I run your code, but the error is triggered after the query open, and it's not from Zeos. Even with the error, the query opens normally ;)

Posted: 31.08.2009, 20:40
by hugleo
Thanks!

DataModule2.QryPesq.Close;

and

DataModule2.Conexao.Disconnect;

solved for me.