Bug if don't activate main form

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
hugleo
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 31.08.2009, 15:16

Bug if don't activate main form

Post 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?
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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).
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
hugleo
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 31.08.2009, 15:16

Post 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.
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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 ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
hugleo
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 31.08.2009, 15:16

Post by hugleo »

Thanks!

DataModule2.QryPesq.Close;

and

DataModule2.Conexao.Disconnect;

solved for me.
Post Reply