Recent

Author Topic: datamodul "unit not used" (IBX)  (Read 1754 times)

Nicole

  • Hero Member
  • *****
  • Posts: 970
datamodul "unit not used" (IBX)
« on: November 29, 2022, 07:27:59 pm »
The base information about my database is in a unit of the type datamodule.
There you can find the path, the name, the logon and the transaction.

All data-sensitive units have this db-modul in their uses clauses.
The TBQueries are in the units, where they have their context.

I do not know if this is "good style", at least it works fine for me.

Nevertheless, I get the hint, that the units "have the datamodul is in the uses clause, although not needed".
And ideas what to do?

rvk

  • Hero Member
  • *****
  • Posts: 6056
Re: datamodul "unit not used" (IBX)
« Reply #1 on: November 29, 2022, 11:01:06 pm »
How do you connect the database component (which is in the dayamodule I assume) to the query component in the unit if the datamodule is not in the uses clause? That shouldn't work.

What is the exact hint?
And what happens if you remove the datamodule from the uses clause?
And how are you connecting the database to the query, via code or object inspector?

If it's code, show those lines (and are you sure the database is in the datamodule).

egsuh

  • Hero Member
  • *****
  • Posts: 1266
Re: datamodul "unit not used" (IBX)
« Reply #2 on: November 30, 2022, 12:46:15 am »
Quote
Nevertheless, I get the hint, that the units "have the datamodul is in the uses clause, although not needed".
And ideas what to do?

Not a big problem itself, but you'd better remove them.

Sometime later, you may want to add another unit in the uses clause, but this time you have missed including the new unit. In this case the program should not work, but it may be working because inadvertently there happen to be a variable of same name in the old datamodule, etc.

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: datamodul "unit not used" (IBX)
« Reply #3 on: November 30, 2022, 06:43:27 pm »
The arrangement is like this:

I drop an TBQuery onto my TFrame
This IBQuery I set to "allow auto activate transaction".

With new frames I had a problem of which I am not sure, how I solved it, because I tried much and copied a working thing into a non-working or so.

The problem was this:
In the property of the IBQuery there was nothing to choose in the field of database. If I key it in by hand, it did not work. And this is the reasong, why I hesitate to delete this
"uses mydatamodul"

I fear, that the stuck-situation will return, that the Frame / IBQuery does not allow me to set the database-property, if I delete the db-module out of the uses-clause.

The data-modul IS used. I get from there: database1, connection1, transaction1

(and.: Thank you so much to the IBX-creators, it works that great and easy once it is set up!)

egsuh

  • Hero Member
  • *****
  • Posts: 1266
Re: datamodul "unit not used" (IBX)
« Reply #4 on: December 01, 2022, 01:41:43 am »
In that case you should have datamodule in uses clause.

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: datamodul "unit not used" (IBX)
« Reply #5 on: December 01, 2022, 03:26:51 pm »
I think so as well.
But how to get rid of the compiler hint and - why is it there?

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: datamodul "unit not used" (IBX)
« Reply #6 on: December 01, 2022, 03:40:15 pm »
My impression is: If you work with the datamodule only at designtime, you do not need to add its unit to the uses clause, because the IDE magically knows about it.

But when you access any of its components and their properties at runtime (i.e. by your own code) you must add the unit to "uses".

To get rid of the warning, right-click on the message in the message window and select "Hide message by inserting IDE directive {%H-}".

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: datamodul "unit not used" (IBX)
« Reply #7 on: December 01, 2022, 03:46:03 pm »
thank you, I will do this.

rvk

  • Hero Member
  • *****
  • Posts: 6056
Re: datamodul "unit not used" (IBX)
« Reply #8 on: December 01, 2022, 04:02:08 pm »
But how to get rid of the compiler hint and - why is it there?
My guess it has to do with the frames.
You mentioned that you use TFrame.

In that case you need the datamodule name in the uses clause of the frame. Not in the uses clause of the actual unit on which you drop the frame.
(unless you mention the database component in the source, in which case there shouldn't be a hint)

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: datamodul "unit not used" (IBX)
« Reply #9 on: December 01, 2022, 04:32:49 pm »
Yes, I work with frames.
Thank you, that you remember this.

No, the database-module is in no way in the source.
Just in the object inspector at design time (I am so glad about).

btw:
Is an IBQuery "very" costly?
Sometimes I wonder if I shall use a several IBQueries or if to re-use the existing ones (and cross fingers, they do never interact).
Mostly I re-use them. There are about 3 IBQueries a frame, dependent on what it does.

rvk

  • Hero Member
  • *****
  • Posts: 6056
Re: datamodul "unit not used" (IBX)
« Reply #10 on: December 01, 2022, 05:07:38 pm »
No, the database-module is in no way in the source.
Just in the object inspector at design time (I am so glad about).
And the TIBQuery is in the TFrame? That means the datamodule only needs to be in the uses of the source of the frame-unit.
NOT in the uses of the form you drop the TFrame on.

btw:
Is an IBQuery "very" costly?
Sometimes I wonder if I shall use a several IBQueries or if to re-use the existing ones (and cross fingers, they do never interact).
Mostly I re-use them. There are about 3 IBQueries a frame, dependent on what it does.
I don't think a TIBQuery is very costly (memory or otherwise). Only when you activate it with a SQL it makes a connection via the TIBDatabase component.
It depends on the queries if you want to keep them open or not.

For an order screen I have queries open for the order itself and some for the customer, contact, address etc.
For other queries which are only temporarily needed, I create queries in runtime and clean them when not needed anymore (I don't reuse them because I create them dynamically).


tonyw

  • Sr. Member
  • ****
  • Posts: 319
    • MWA Software
Re: datamodul "unit not used" (IBX)
« Reply #11 on: December 01, 2022, 11:59:11 pm »
The base information about my database is in a unit of the type datamodule.
There you can find the path, the name, the logon and the transaction.

All data-sensitive units have this db-modul in their uses clauses.
The TBQueries are in the units, where they have their context.

I do not know if this is "good style", at least it works fine for me.

Nevertheless, I get the hint, that the units "have the datamodul is in the uses clause, although not needed".
And ideas what to do?
This seems to be a feature  of the IDE. The datamodule is not referenced in the .pas file and hence the "hint". However, if you do not include it in a uses clause then, when you try to connect a TDataset (e.g. a TIBQuery) to a database in the datamodule, then it will not appear in the drop down list of databases shown in the Object Inspector. Bottom line is that if you want to use the Object Inspector to link up objects in the datamodule to objects on your Form/Frame then you need to include the datamodule in your uses clause.
« Last Edit: December 02, 2022, 12:07:21 am by tonyw »

egsuh

  • Hero Member
  • *****
  • Posts: 1266
Re: datamodul "unit not used" (IBX)
« Reply #12 on: December 02, 2022, 12:57:43 am »
Maybe your frames own datasets and you are trying to connect within a form containing the frame.

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: datamodul "unit not used" (IBX)
« Reply #13 on: December 02, 2022, 01:24:05 pm »
Maybe your frames own datasets and you are trying to connect within a form containing the frame.

This goes thrilling.
I have not understand this sentence in full, but it sounds like a clou.

This way it works:
I have a unit form main with a page control.
Then I have my frames and my db modul, which is used by many of those frames.

The create-event of the form makes the frames created and fixed to the tabs of the Pagecontrol.
This way I can develop one part of my software after the other and use the working parts.

in other words
- created are a Form1 and the dbmodul
- the create of form1 creates the frames, which use the dbmodul.

egsuh

  • Hero Member
  • *****
  • Posts: 1266
Re: datamodul "unit not used" (IBX)
« Reply #14 on: December 02, 2022, 05:13:37 pm »
The frames must have dbmodule in uses clause.
But you may not need it in the "FORM", which contains the frames. The hint may be from the form's unit.



 

TinyPortal © 2005-2018