Changing Btrieve Table Definitions

Automatic Btrieve Table Conversion while Developing

To Enable it, call the following method

ENV.Utilities.TableDefinitionConverter.EnableBtrieveAutoConversion(); 
  1. Make sure to open the Entity List (Shift F2) and view the table data before the change.
  2. Make the change to the Entity class as you want.
  3. Build and run the code.
  4. Next time that you'll open the table in the Entity List you'll get a message asking if you want to convert the actual data.

2018 09 14 09H42 03

  1. The conversion will create a backup of the original file with the date and time of the conversion in it's name. for example nwfil001.dat_mch_2018-09-13_05-48-00.
  2. Once the conversion is done, it'll offer you to copy the code that did the conversion, whuch you can use in your code to run the conversion automatically.

Converting Btrieve Tables from the code

Item 6 in the previous header will provide you with the code to run the conversion automatically. Here's the code from the video:

// Copy this code to a database migration program
var oldDef = "AAEAAAD/////AQAAAAAAAAAMAgAAAD9FTlYsIFZlcnNpb249My40LjI0LjMwNzQwLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwFAQAAAB1FTlYuVXRpbGl0aWVzLlRhYmxlRGVmaW5pdGlvbggAAAAIVHlwZU5hbWUHU3FsTmFtZQdDYXB0aW9uCVNxbFNjaGVtYQtCdHJpZXZlTmFtZQVPd25lcgdDb2x1bW5zB0luZGV4ZXMBAQEBAQEEBCBFTlYuVXRpbGl0aWVzLkNvbHVtbkRlZmluaXRpb25bXQIAAAAfRU5WLlV0aWxpdGllcy5JbmRleERlZmluaXRpb25bXQIAAAACAAAABgMAAAAaTm9ydGh3aW5kLk1vZGVscy5DdXN0b21lcnMGBAAAAAlDdXN0b21lcnMJBAAAAAYFAAAAI0M6XEZpcmVmbHlNaWdyYXRpb25cTm9ydGh3aW5kXERhdGFcBgYAAAAMbndmaWwwMDEuZGF0CgkHAAAACQgAAAAHBwAAAAABAAAACwAAAAQeRU5WLlV0aWxpdGllcy5Db2x1bW5EZWZpbml0aW9uAgAAAAkJAAAACQoAAAAJCwAAAAkMAAAACQ0AAAAJDgAAAAkPAAAACRAAAAAJEQAAAAkSAAAACRMAAAAHCAAAAA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W5pdGlvbgIAAAAJWwAAAAdWAAAAAAEAAAABAAAABB9FTlYuVXRpbGl0aWVzLlNlZ21lbnREZWZpbml0aW9uAgAAAAlcAAAAB1gAAAAAAQAAAAEAAAAEH0VOVi5VdGlsaXRpZXMuU2VnbWVudERlZmluaXRpb24CAAAACV0AAAAFWQAAAB9FTlYuVXRpbGl0aWVzLlNlZ21lbnREZWZpbml0aW9uAgAAAApDb2x1bW5OYW1lCkRlc2NlbmRpbmcBAAECAAAACRwAAAAAAVoAAABZAAAACTAAAAAAAVsAAABZAAAACSAAAAAAAVwAAABZAAAACTgAAAAAAV0AAABZAAAACTQAAAAACw==";
var customers = new Northwind.Models.Customers();
ENV.Utilities.TableDefinitionConverter.Convert(newDef, oldDef, customers.DataProvider, @"nwfil001.dat"); 

Let's review this code.

  1. oldDef - the original structure of the btrieve table in Base64 format. you can obtain that by right clicking on an Btrieve Entity in the Entity Browser and select Copy Btrieve Definition as Base64 string Getting Definition Base64
  2. newDef - the new structure of the Btrieve table in Base64 format.
  3. an instance of the entity.
  4. Calling the Convert method that recieves the newDev, oldDef, DataProvider and filename to convert.

If you want to translate the Base64 to a readable object, use the ENV.Utilities.TableDefinitionConverter.FromBase64 method.



Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com