Recent

Author Topic: VisualPlanit using Zeos and MySql  (Read 551 times)

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 106
VisualPlanit using Zeos and MySql
« on: May 20, 2022, 07:56:19 am »
Hi all,
in the routine FixContactsTable ( unit VpZeosDs ) I suggest to change  the code from
Code: Pascal  [Select][+][-]
  1.   FConnection.Connected := false;
  2.   FConnection.AutoCommit := autocommit;
  3.   FConnection.Connected := true;
  4.  
to

Code: Pascal  [Select][+][-]
  1.   FConnection.AutoCommit := autocommit;
  2.  

in order to do not close the connection already in use for some others form.

Is it applicable ?
Many thanks

af0815

  • Hero Member
  • *****
  • Posts: 951
Re: VisualPlanit using Zeos and MySql
« Reply #1 on: May 20, 2022, 11:22:16 am »
Without closing and reconnecting the AutoCommit is not accepted. Changing some parameter on the connection need to close it before changing parameters. So it is not a good idea to change this in the code.
regards
Andreas

wp

  • Hero Member
  • *****
  • Posts: 9759
Re: VisualPlanit using Zeos and MySql
« Reply #2 on: May 20, 2022, 05:37:28 pm »
I am not sure whether the FixContactsTable really needs to be as it is at the moment. Please set up a little project for me to see your issue. Only very simple, please, and no exotic database system, sqlite3 is fine.

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 106
Re: VisualPlanit using Zeos and MySql
« Reply #3 on: May 21, 2022, 07:26:27 am »
Many thanks for your answers.

I am not using an "exotic" database but MySQL.

I can share a little project but this is not the point.

In relational databases - in MySQL for sure - the ALTER/CREATE/DROP ect ect table comands and similar (metadata update) are always excluded from transaction.

The AutoCommit setted to true is unuseful.

Anyway if you still need a sample project please let me know what is its purpose in order to create it as you require.

wp

  • Hero Member
  • *****
  • Posts: 9759
Re: VisualPlanit using Zeos and MySql
« Reply #4 on: May 23, 2022, 01:17:47 pm »
I am not using an "exotic" database but MySQL.
Exotic for me...

I am rather sure that FixContactsTable is quite obsolete in most cases. Because the tables created since the zeos datastore is existing very probably have the fields of the Lazarus version (FixContactsTable converts the Contacts table from fields used in the old Delphi version to the fields used now in the Lazarus version).

I don't understand why it is executed without a version check. Now I added whether a field of the Lazarus version already exists, and in this case, the procedure FixContactsTable is not entered at all.

Please test the development version on Lazarus CCR (https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/tvplanit/), or replace the "if FConnection.Connected and TablesExist" block in procedure TVpZeosDatastore.SetConnected, unit VpZeosDS, by the following lines
Code: Pascal  [Select][+][-]
  1. procedure TVpZeosDatastore.SetConnected
  2. ...
  3. begin
  4.   ...
  5.   if FConnection.Connected and TablesExist then begin
  6.     FContactsTable.Open;
  7.     // If field "Department" does not exist then it is an old table and must be reworked.
  8.     if ContactsTable.Fields.FindField('Department') = nil then
  9.     begin
  10.       FixContactsTable;
  11.       FContactsTable.Open;
  12.     end;
  13.     FEventsTable.Open;
  14.     FResourceTable.Open;
  15.     FTasksTable.Open;
  16.     canLoad := true;
  17.   end;
  18.   ...  

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 106
Re: VisualPlanit using Zeos and MySql
« Reply #5 on: May 24, 2022, 09:21:34 am »
I changed the coda as you suggest and it works.

Many thanks,

 

TinyPortal © 2005-2018