Recent

Author Topic: Error - Transaction of connection not set  (Read 8827 times)

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Error - Transaction of connection not set
« Reply #15 on: September 02, 2018, 08:06:24 am »
Considering that most of the forms of the project deals with three or less tables. Instead of heaving more than one thousand files (forms) in the project, do you suggest to have more than two thousand files (forms and data modules)?
No, by converting them to datamodules you will have the opportunity to use a single datamodule for multiple forms for example if the only difference between the 10 datamodules is the select query then create a single datamodule, pass that query as a parameter at the module's creation time and use it from the 10 different forms.
This is not compliant to the KISS principle.
Here in Brazil, your suggestion would be considered "Programação Orientada a Gambiarras (POG)", something similiar to "Workaround-Oriented Programming (WOP).  :)
I guess its a point of view. The described process is a good example of a top down design process. There is nothing "workaround" about it.
Now it is being migrated to Lazarus. It will not be rewritten from scratch, it will only be migrated in the simplest way for the shortest possible time and at the lowest possible cost.
then its a waste of time and effort to port it to lazarus. stop and start working on the web version the faster it will finish the faster the old app will be decommissioned.
 
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #16 on: September 02, 2018, 08:15:31 am »
Quote
or even better do not use the form2's transaction as the default transaction of the database
Revisit the sample project. Form2's transaction is not the default transaction of the connection.
Yes it is, see attached image.
The image you attached is showing Form1, IBConnection1, SQLTransaction1, which is the default transaction of the connection.
But we are talking about Form2, no IBConnection, SQLTransaction2, which is the individual transaction for SQLQuery2.
See attached image.

Quote
Quote
use it only as the transaction of the queries on form2.
It already is.
then why you need it to be the default transaction of the connection?
The default transaction (SQLTransaction1 on Form1) is necessary for IBConnection1 to do internal jobs, such as build automatically (ParseSQL) Insert, Update and Delete commands for a provided Select.

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Error - Transaction of connection not set
« Reply #17 on: September 02, 2018, 08:21:16 am »
Quote
or even better do not use the form2's transaction as the default transaction of the database
Revisit the sample project. Form2's transaction is not the default transaction of the connection.
Yes it is, see attached image.
The image you attached is showing Form1, IBConnection1, SQLTransaction1, which is the default transaction of the connection.
But we are talking about Form2, no IBConnection, SQLTransaction2, which is the individual transaction for SQLQuery2.
See attached image.
no it does not. look at the object inspector on the left. The focused transaction property says otherwise.

PS
  you might have to set the transaction's connection property instead though.
« Last Edit: September 02, 2018, 08:23:21 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #18 on: September 02, 2018, 08:37:15 am »
Now it is being migrated to Lazarus. It will not be rewritten from scratch, it will only be migrated in the simplest way for the shortest possible time and at the lowest possible cost.
Quote
then its a waste of time and effort to port it to lazarus.
No, it's not. It is faster and less expensive. It's a RAD project.

Quote
stop and start working on the web version the faster it will finish the faster the old app will be decommissioned.
The web and mobile project would cost ten times more and it would be developed three times slower than the desktop project.
I know that by other clients that are doing it...
Build a small ERP is not an easy task for a desktop application, but it's a real challenge for web and mobile applications.
Legal system (sell and buy products and services, pay taxes, etc) in Brazil is not for beginners.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #19 on: September 02, 2018, 09:09:16 am »
Quote
or even better do not use the form2's transaction as the default transaction of the database
Revisit the sample project. Form2's transaction is not the default transaction of the connection.
Yes it is, see attached image.
The image you attached is showing Form1, IBConnection1, SQLTransaction1, which is the default transaction of the connection.
But we are talking about Form2, no IBConnection, SQLTransaction2, which is the individual transaction for SQLQuery2.
See attached image.
no it does not. look at the object inspector on the left. The focused transaction property says otherwise.

PS
  you might have to set the transaction's connection property instead though.
You are right. And this matter seems to be solved.
Thanks you so much.

But now, it seems we have a real bug.
Detail data module sees master data module, but not the contrary in the actual application, exactly as the sample project I have provided.
How that information was transported from detail data module (Form2) to master data module (Form1) during design time?
I will create another sample project from scratch to figure it out.

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Error - Transaction of connection not set
« Reply #20 on: September 02, 2018, 09:20:23 am »
But now, it seems we have a real bug.
Detail data module sees master data module, but not the contrary in the actual application, exactly as the sample project I have provided.
How that information was transported from detail data module (Form2) to master data module (Form1) during design time?
Which is the detail and which is the master? If I assume that form1 is the master and form2 the detail then the detail needs to see the master and connect the sqlquery to the IBConnection, that's the only link required for the query to be able to talk to the database and consequently to the master data module.
I will create another sample project from scratch to figure it out.
That would be helpful in case I misunderstood the description above.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

mangakissa

  • Hero Member
  • *****
  • Posts: 1101
Re: Error - Transaction of connection not set
« Reply #21 on: September 02, 2018, 11:41:37 am »
Back to the original problem. I put this line of code in your sample:
Code: Pascal  [Select][+][-]
  1. procedure TForm2.FormShow(Sender: TObject);
  2. begin
  3.   Form2.SQLQuery2.DataBase := Form1.IBConnection1 ;
  4.   Form2.SQLQuery2.Transaction := Form2.SQLTransaction2;
  5.   Form2.SQLTransaction2.DataBase := Form1.IBConnection1;
  6. end;
  7.  
It results with the same error (no connection or transaction). That's strange, because the link to the database and transaction is linked @runtime.
I even put an showmessage on OnShow to check if Form.IBConnection1 is available.

At this point I don't now where the problem exists. With a datamodule it works fine.

Quote
Application is build in D2 originally
Now I understand why all datacomponents are put on form. But when converting to D7 it was the best thing to build the application on datamodule
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #22 on: September 03, 2018, 02:56:04 pm »
But now, it seems we have a real bug.
Detail data module sees master data module, but not the contrary in the actual application, exactly as the sample project I have provided.
How that information was transported from detail data module (Form2) to master data module (Form1) during design time?
Which is the detail and which is the master? If I assume that form1 is the master and form2 the detail
Correct.

Quote
then the detail needs to see the master and connect the sqlquery to the IBConnection, that's the only link required for the query to be able to talk to the database and consequently to the master data module.
I know that, but in this case, each form needs its own transaction.
I will relate below what I have discovered so far.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #23 on: September 03, 2018, 03:01:00 pm »
Back to the original problem. I put this line of code in your sample:
Code: Pascal  [Select][+][-]
  1. procedure TForm2.FormShow(Sender: TObject);
  2. begin
  3.   Form2.SQLQuery2.DataBase := Form1.IBConnection1 ;
  4.   Form2.SQLQuery2.Transaction := Form2.SQLTransaction2;
  5.   Form2.SQLTransaction2.DataBase := Form1.IBConnection1;
  6. end;
It results with the same error (no connection or transaction). That's strange, because the link to the database and transaction is linked @runtime.
I even put an showmessage on OnShow to check if Form.IBConnection1 is available.

At this point I don't now where the problem exists.
I can confirm and I believe this is a bug. Otherwise, forms would have to be forbidden to have SQLdb components.

Quote
With a datamodule it works fine.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #24 on: September 03, 2018, 03:06:00 pm »
Application is build in D2 originally.
Now I understand why all datacomponents are put on form.
But when converting to D7 it was the best thing to build the application on datamodule
I respect you opinion, but I believe that data modules should not be a panacea, like anything else.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #25 on: September 03, 2018, 03:17:05 pm »
First case:

1. Create a new project;
2. Put a IBConection1 on Form1;
3. Create Form2;
4. Put a SQLTransaction2 on Form2;
5. Set SQLTransaction2.Database as Form1.IBConection1;
6. Check Form1.IBConection1.Transaction information.

Why Form2.SQLTransaction2 has became the default transaction of Form1.IBConection1 if Form2 is not even in Form1's uses sections?

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #26 on: September 03, 2018, 03:32:46 pm »
Second case:

1. Create a new project;
2. Put a IBConection1 on Form1;
3. Create Form2;
4. Put a SQLTransaction2 on Form2;
5. Create Form3;
6. Put a SQLTransaction3 on Form3;
7. Check Form1.IBConection1.Transaction information.

Why Form1.IBConection1 permits see Form2.SQLTransaction2 and Form3.SQLTransaction3 if Form2 and Form3 are not even in Form1's uses sections?

Isn't this case a bug in design time information?

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Error - Transaction of connection not set
« Reply #27 on: September 03, 2018, 03:34:52 pm »
First case:

1. Create a new project;
2. Put a IBConection1 on Form1;
3. Create Form2;
4. Put a SQLTransaction2 on Form2;
5. Set SQLTransaction2.Database as Form1.IBConection1;
6. Check Form1.IBConection1.Transaction information.

Why Form2.SQLTransaction2 has became the default transaction of Form1.IBConection1 if Form2 is not even in Form1's uses sections?
Because SQLTransaction2 (which is the control that sets the Transaction property on the IBConnection) has no information of form1's use list nor form2's. You can stop that by setting the IConnection transaction property to something else before setting the SQLTransaction.Database property.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Error - Transaction of connection not set
« Reply #28 on: September 03, 2018, 03:38:16 pm »
Second case:

1. Create a new project;
2. Put a IBConection1 on Form1;
3. Create Form2;
4. Put a SQLTransaction2 on Form2;
5. Create Form3;
6. Put a SQLTransaction3 on Form3;
7. Check Form1.IBConection1.Transaction information.

Why Form1.IBConection1 permits see Form2.SQLTransaction2 and Form3.SQLTransaction3 if Form2 and Form3 are not even in Form1's uses sections?

Isn't this case a bug in design time information?
That's a feature of the IDE Designer, once you link a property to a control on an other form it will automatically append that form to the uses clause.

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1008
Re: Error - Transaction of connection not set
« Reply #29 on: September 03, 2018, 03:43:10 pm »
First case:

1. Create a new project;
2. Put a IBConection1 on Form1;
3. Create Form2;
4. Put a SQLTransaction2 on Form2;
5. Set SQLTransaction2.Database as Form1.IBConection1;
6. Check Form1.IBConection1.Transaction information.

Why Form2.SQLTransaction2 has became the default transaction of Form1.IBConection1 if Form2 is not even in Form1's uses sections?
Because SQLTransaction2 (which is the control that sets the Transaction property on the IBConnection) has no information of form1's use list nor form2's. You can stop that by setting the IConnection transaction property to something else before setting the SQLTransaction.Database property.
Isn't a bug when design time allows something that run time won't?

 

TinyPortal © 2005-2018