[solution] Migration from ZEOS to DAC

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
waheed
Posts: 20
Joined: Mon 02 Nov 2009 19:47
Location: Kuwait

[solution] Migration from ZEOS to DAC

Post by waheed » Sun 06 Dec 2009 18:58

After hours of converting my application from ZEOS to DAC for MySQL, I have came up with a "few" things to do. Of course you will need a few tools to help you do the job.

Assumption: You use Y and N as ENUM for boolean fields in MySQL. And you don't want to change the database.

If you used ENUM in MySQL to represent Boolean fields in ZEOS then you should know that DAC is different. In DAC you use TinyInt in MySQL to represent Boolean fields where the values 0 for False and 1 for True.

* GExperts at http://www.gexperts.org/: I used Grep Search a lot to find items in the files.
* Beyond Compare at http://www.scootersoftware.com/:

Of course you need to backup your project before starting the migration steps. I take no responsibility for any problems.

In dfm files using (opened as text)
* Replace TZConnection with TMyConnection and User to UserName and delete Protocol and TransactIsolationLevel properties.
* Replace TZQuery with TMyQuery
* Replace TZReadOnlyQuery with TMyQuery and add ReadOnly = True be careful to do this step in the same time or you might loose track of which is which.
* Replace TZTable with TMyTable
* Replace LinkedFields property with DetailFields
* Replace SortedFields property by IndexFieldNames if needed
* Delete WhereMode property from TMyQuery
* Delete ShowRecordTypes property.
* Replace TZUpdateSQL with TMyUpdateSQL component notice that TMyQuery already have the updates properties and you might not need a TMyUpdate any way
* Delete All Params properties from UpdateSQL components since it is not there
* Delete UseSequenceFieldForRefreshSQL from UpdateSQL components
* Replace TBooleanField with TStringField unless you used TinyInt as mentioned later.
* If you have FastReport and you have installed it related components, then replace frxZEOSDatabase with frxMyDacDatabase.
* In DBCheckbox component change the ValueCheck property from True to Y and the ValueUnchecked from False to N.

In Pas code files
* Replace EZSQLException with EMyError and add MyClasses to the uses
* Replace LinkedFields code lines with DetailFields
* Change all ENUM boolean to String, so .AsBoolean becodes .AsString='Y' or .AsString='N'
* Also when you use booleans in the form .Value change it to .Value='Y' or .Value='N'
* Don't forget to add parantheses to those comparisons
* SortedFields don't exist in MyDAC so replace them with IndexFieldNames
* If you used frxMyDacDatabase change HostName property to Server
* Also for frxMyDacDatabase change User property to UserName
* In frxMyDacDatabase remove Protocol
* Replace ParamByName with Params.ParamByName


Units used:
* Replace ZConnection with .
* Replace ZConnection, ZAbstractRODataset, ZAbstractDataset, ZAbstractTable, ZDataset, ZSqlUpdate with MyAccess, MemDS, DBAccess.

In design
* Disable "EnableBoolean" if you use TinyInt values for other non boolean fields (TinyInt is used as boolean field in DAC)

Finally, I was successfull in the migration. Although I didn't like the last point. I will find a way in future to correct this.

PS. If there is any problems or mistakes in this article please tell us. Hope this help others in migrating to DAC for MySQL. This is my second experience.
PS.2: My next project is to convert from MyDAC to SDAC. Which I will post in SDAC forum.
PS.3: Updates are in BOLD
Last edited by waheed on Sat 10 Apr 2010 17:57, edited 14 times in total.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 07 Dec 2009 10:25

Thank you very much for the information. We will investigate the possibility of adding this functionality in the near future.

waheed
Posts: 20
Joined: Mon 02 Nov 2009 19:47
Location: Kuwait

Post by waheed » Mon 07 Dec 2009 12:02

Any changes I will do it on the original post.

Post Reply