Forum > Databases

VisualPlanit using Zeos and MySql

(1/2) > >>

Nicola Gorlandi:
Hi all,
in the routine FixContactsTable ( unit VpZeosDs ) I suggest to change  the code from

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  FConnection.Connected := false;  FConnection.AutoCommit := autocommit;  FConnection.Connected := true;  to


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  FConnection.AutoCommit := autocommit; 
in order to do not close the connection already in use for some others form.

Is it applicable ?
Many thanks

af0815:
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.

wp:
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:
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:

--- Quote from: Nicola Gorlandi on May 21, 2022, 07:26:27 am ---I am not using an "exotic" database but MySQL.

--- End quote ---
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TVpZeosDatastore.SetConnected...begin  ...  if FConnection.Connected and TablesExist then begin    FContactsTable.Open;    // If field "Department" does not exist then it is an old table and must be reworked.    if ContactsTable.Fields.FindField('Department') = nil then    begin      FixContactsTable;      FContactsTable.Open;    end;    FEventsTable.Open;    FResourceTable.Open;    FTasksTable.Open;    canLoad := true;  end;  ...  

Navigation

[0] Message Index

[#] Next page

Go to full version