Recent

Author Topic: multiple data modules and zeos components  (Read 10739 times)

paologri

  • Newbie
  • Posts: 3
multiple data modules and zeos components
« on: March 12, 2011, 07:50:23 pm »
hi,
I am a Lazarus newbie and I have a problem with data modules.
In my application, I have a data module (DMConnection) with only a component zconnection, and some other data modules (DMclienti,DMordini,DMprodotti,ecc..) with some other Zeos components (ZQuery, ZReadOnlyQuery,ZTable) and DataSources. Every component has the same connection (zconnection in DMConnection). If I link these components at dbgrids in some forms, I see data at design time and for me the connection is active; but if I launch application I have a run time error : 'EZDatabaseError:Database connection component is not assigned'.
In project option I have assigned form in this order:
DMConnection
DMclienti
DMordini
DMprodotti
frmClienti
frmOrdini
frmProdotti

I think that the data modules DMclienti, DMordini, DMprodotti don't see DMConnection but why I don't now
My lazarus version is 0.9.31 fpc 2.4.3 zeos 7.0.0 and RXlib

Is my mistake or is there a workaround ?

Paolog

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: multiple data modules and zeos components
« Reply #1 on: March 13, 2011, 02:10:37 am »

I think that the data modules DMclienti, DMordini, DMprodotti don't see DMConnection but why I don't now
My lazarus version is 0.9.31 fpc 2.4.3 zeos 7.0.0 and RXlib

Is my mistake or is there a workaround ?

is the datamodule with the dmconnection earlier in the form create order?


paologri

  • Newbie
  • Posts: 3
Re: multiple data modules and zeos components
« Reply #2 on: March 13, 2011, 09:41:19 am »
yes,
the order i think is correct:
before all data modules (first the module with connection) and after the forms.
If I put a connection component in every data modules, the application work correctly.
the problem is when I use a separate data module with one connection component shared by all other data modules....
paolog
« Last Edit: March 13, 2011, 09:46:33 am by paologri »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: multiple data modules and zeos components
« Reply #3 on: March 13, 2011, 12:43:39 pm »
yes,
the order i think is correct:
before all data modules (first the module with connection) and after the forms.
If I put a connection component in every data modules, the application work correctly.
the problem is when I use a separate data module with one connection component shared by all other data modules....
paolog

The forms are maybe linked to the datamodules via e.g. dbgrids and other db aware controls. I'd say first the dm module with the connection, then the other dms, and only then the forms.

paologri

  • Newbie
  • Posts: 3
Re: multiple data modules and zeos components
« Reply #4 on: March 13, 2011, 04:37:25 pm »

The forms are maybe linked to the datamodules via e.g. dbgrids and other db aware controls. I'd say first the dm module with the connection, then the other dms, and only then the forms.

Yes,
is exactly what I did.
At design time is OK: I see data(the records) in rxdbgrid, but at run time .....
this is my .lpr file:

------------------------------------------------------------------------------------
program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, rxnew, zcomponent, Unit1, dmconnection, dmdatasource;

{$R *.res}

begin
  RequireDerivedFormResource := True;
  Application.Initialize;
  Application.CreateForm(TDMConn, DMConn);  <--- this is Data module with Zconnection comp.
  Application.CreateForm(TDMDS, DMDS);        <--- this is Data module with zTable, datasource
                                                                       (Ztable is linked with Zconnection component)
  Application.CreateForm(TForm1, Form1);       <--- this is form with dbgrid (is linked with datasource)
  Application.Run;
end.
------------------------------------------------------------------------------------
at row: Application.CreateForm(TDMDS, DMDS); there is the error:

Project projecr1.exe raised exception class 'EZDatabaseError' with massage:
Database connection component is not assigned
!
Paolog

« Last Edit: March 13, 2011, 04:41:41 pm by paologri »

solidsnakeit

  • Newbie
  • Posts: 1
Re: multiple data modules and zeos components
« Reply #5 on: April 04, 2013, 11:20:28 am »
I've the same problem.
There's news?

bills

  • New Member
  • *
  • Posts: 44
Re: multiple data modules and zeos components
« Reply #6 on: April 07, 2013, 07:27:55 am »
Before open the ZROQuery, you shuld add this line:

ZROQuery.Connection := DMConn.ZConnection

 

TinyPortal © 2005-2018