Page 1 of 1

Database component is not assigned

Posted: 23.12.2011, 05:06
by mochhenry
when i use TZConnection in the same form this error doesnot show.
when i use TZConnection in the datamodule this error always show.

can you help me please.

:( :( :( :(

lazarus 0.9.28
zeos 6.6.6
ubuntu 10.04

Posted: 28.12.2011, 10:58
by Zoran
I cannot reproduce this problem. I put ZConnection1 on DataModule1, set the properties so that it connects to data base, then I put ZReadOnlyQuery1 on form1, set ZReadOnlyQuery1.Connection to DataModule1.ZConnection1, set SQL to a select statement and everything works well.

Why do you use Lazarus version 0.9.28, which is more than two years old? Maybe the problem is there.
I tried with "stable" Lazarus 0.9.30.2 and 0.9.31 from trunk.

Does the problem appear in design time or in runtime?

Posted: 28.12.2011, 18:13
by papelhigienico
Check the creation order and if the datamodule was put on auto-create forms list.

Posted: 30.12.2011, 16:53
by mdaems
I second papelhigienico's view. This error usually comes from the datamodule being created after the form instance is created.

Mark

Posted: 16.07.2013, 15:21
by jwhitten
I know this is a response to an old thread but...

In my experience, when you get the "Database connection is not assigned" error, it means that you left a dataset (TZTable, TZQuery, whatever) in the "Active" (Active := True) state before running the program. IMO, this should not be a problem, but it happens to me quite frequently and that's what I've discovered quickly fixes the issue. Just go in, select 'em all, and set them to False and it will probably work after that-- assuming you really are hooking them up with a connection of course.

BTW, in case anybody's wondering, I'm using Zeosdb 7.4 something or other, a very recent copy from subversion, along with Lazarus 1.0.10. So this issue is definitely still around.

John