Recent

Author Topic: TSQLQuery.Transaction setting automatically to TIBConnection.Transaction v. 1.6  (Read 4207 times)

EdyKnopfler

  • New Member
  • *
  • Posts: 12
Hello,

I have a DataModule with one IBConnection and some SQLTransactions, and a number of SQLQueries so that each one is supposed to point to the right SQLTransaction. It used to work in Lazarus 1.0.4.

After installing v. 1.6, every time I create an instance of the DataModule, the Transaction property of all my SQLQ's are pointing back to IBConnection default transaction. It even happens in design time: I open the DataModule and all SQLQueries point the Transaction property to the wrong component!

A workaround that worked was do:

MyQuery.Transaction := TheRightTransaction;  // i shouldn't be doing this :(

Is something wrong with the components or is there something that changed and I don't know?

LacaK

  • Hero Member
  • *****
  • Posts: 691
There was patch IIRC which changes something in this direcion.
May be, that in some cases is there negative impact. Probably it depend in which order properties of object are read from LFM and assigned to TSQLQuery properties (there are Database and Transaction properties and may be that one resets other ...)

Can you look in your DataModule LFM in whicj order comes these properties ... ?

EdyKnopfler

  • New Member
  • *
  • Posts: 12
First Database, then Transaction.

LacaK

  • Hero Member
  • *****
  • Posts: 691
Strange.
Later setting "Transaction" should overwrite "Database" ... when you do in code:

MyQuery.Database := TheRightConnection;
MyQuery.Transaction := TheRightTransaction;

Then all is okay ?

Btw in LFM file, where is located TSQLTransaction and TSQLConnection ... before TSQLQuery objects ? If not try put it before ...

EdyKnopfler

  • New Member
  • *
  • Posts: 12
Yes, setting the properties programatically after the creation does work.

Actually I have a DataModule superclass, with the IBConnection, one SQLTransaction and one SQLQuery. These are used for some basic tasks like querying generators.

The real DataModule created at the start of the app is a subclass of that. In its .dfm file, the order is:

- the IBConnection, the SQLTransaction and the SQLQuery inherited from the superclass
- all the SQLTransactions introduced in the inherited DM
- all the SQLQueries introduced in the inherited DM (basically, the order I put them at the designer)

In another project I follow other structure: separate but not inheritance-linked DM's. The problem doesn't appear.
« Last Edit: July 26, 2016, 04:23:52 am by EdyKnopfler »

LacaK

  • Hero Member
  • *****
  • Posts: 691
Really interesting.
Still I do not understand what is hapen in background.

My guess is that somehow order how values from LFM are assigned to properties of declared object changed.

From your symptoms I guess, that in case of TSQLQuery objects, first is assigned Transaction value and later Database value, which overwrites previously set Transaction and causes that new Database.Transaction is assigned (which resets all TSQLQuery.Transactions to same Database.Transaction values).
As you wrote it does not happens in other applications ...

I always was thinking, that properties from LFM are read and assigned in sequential way from top to bottom, so if Database precedes Transaction there shouldn't be a problem.

 

TinyPortal © 2005-2018