How Do I Account for Incompatibilities in Table Structure Between Magic xpa and the Database? (Magic xpa 4.x)
When you are working with an ISAM table, there is always the possibility that the table as it exists does not match the table definition in Magic xpa. This can happen if changes were made in Magic xpa and the changes were not made in the DBMS, or vice versa, or if two different Magic xpa projects are not kept in sync with each other.
-
First, close your project, if a project is open.
-
Then go to Options->Settings->Databases.
-
Select the database you want to work with, and press Alt+Enter to bring up the Database Properties.
-
Click on the Options tab.
-
Make sure Change Tables in Studio is checked.
If Change Tables in Studio is checked, then when you make some change to the table definition in the Data repository, Magic xpa will automatically take care of converting the actual table. Magic xpa will convert the actual data (if any exists) and also the definition of the table within the DBMS.
For instance, if you were to change a field definition from Numeric to Alpha in a given table, then exit, you would receive a message such as:
When you click on Yes, Magic xpa will convert the numeric data 3 to the alpha text ‘3’. Magic xpa will also handle the changes if you shuffle the field positions, or change the indexes.
It is, however, important that if you change the table, you allow Magic xpa to convert the data each time. If the Confirmation box appears, and you click No, then the table definition will be out of sync with the data.
While you are testing, you can allow Magic xpa to automatically test that the data is synchronized, for ISAM tables. To do this:
-
First, close your project, if a project is open.
-
Then go to Options->Settings->Databases.
-
Select the database you want to work with, and press Alt+Enter to bring up the Database Properties.
-
Click on the Options tab.
-
Make sure Check Definition is checked.
Now, if you try to access a table that is not in sync, you will get a message, such as Definition mismatch, data source::
Also, an error event will be raised, which you can trap to log and give a meaningful message to the user.