Compatibility Issues with DataFlex 19.1+¶
Description¶
DataFlex 2019+ programs using Mertech Flex2SQL Classic Drivers will compile and run succesfully if using exclusively DataFlex commands. However, if Flex2SQL Classic commands or attributes are used, compilation will fail. The use of Flex2SQL Classic commands and attributes requires the inclusion of the mertech.inc file. This file conflicts with some of the DataAccess files. To remedy the situation, some changes must be made to the .src file of the project.
- We will discuss 2 senarios:
The program uses exclusively DataFlex commands with hardcoded server login.
The program uses both DataFlex and Flex2SQL Classic commands.
In both senarios, we will use the DataAccess Order Entry example workspace. To start with, the Orders.src looks something like:
Use OrderPrecompile.pkg
Use DfAllent.pkg
Use cCJStandardCommandBarSystem.pkg
Use cToolTipController.pkg
Use cCJCommandBarSystem.pkg
Object oHtmlHelp is a cHtmlHelp
End_Object
Object oApplication is a cApplication
Set psCompany to "Data Access Worldwide"
Set psProduct to "DataFlex Examples"
Set psVersion to "19.1"
Set psProgram to "Order"
Set psHelpFile to "DevelopmentGuide.chm"
Set peHelpType to htHtmlHelp
Object oConnection is a cConnection
Use LoginEncryption.pkg
Use DatabaseLoginDialog.dg
End_Object
End_Object
Object oToolTipController is a cToolTipController
Move Self to ghoToolTipController
End_Object
Use oEditContextMenu.pkg
Use oDEOEditContextMenu17.pkg
Object oMain is a Panel
Set Label to "Order Entry Sample Application"
Set Location to 4 3
Set Size to 300 450
....menu code here......
Object oClientArea is a ClientArea
Use Customer.vw
Use Inventory.vw
Use Order.vw
Use SalesPerson.vw
Use Vendor.vw
.....some other Use statements here...............
Use StdAbout.pkg
Procedure Activate_About
Send DoAbout "Order Entry Sample Application" "19.1.0.0" "Copyright (c) 2021 Data Access Corporation" "Data Access Worldwide" ""
End_Procedure
End_Object
End_Object
Start_UI
Senario #1: Use only DataFlex commands, hardcoded server login¶
There are 2 ways this can be done, by utilizing the Mertech.ini file or using the .int files of your tables.
Using the Mertech.ini file
After using Flex2SQL Utility Classic to convert your data, you can copy the Mertech.ini file from the Mertech Data SystemsDB DriversDataFlexbin folder (typically located in C:Program Files (x86)) to the same folder as your executable. By following the directions in Understanding Mertech Files,Mertech.ini you can enter all of your server and database information. Your program will compile and run as it always has. Just remember that if you deploy your program, you must have the Mertech.ini file where the program can find it. Note: DataFlex will use the mertech.ini file in it’s Bin (typically C:Program Files (x86)DataFlex xx.xBin) folder BEFORE looking in your workspace Programs folder.
Using the .int files
- When creating the .int files, you will need the Database Name in the file. To do this automatically when converting you files:
Start up the Flex2SQL Utility Classic and log into your server and database.
Select Tools | Preferences from the main menu.
Select the Login tab in the Preferences dialog box.
Check Put Database Name into INT file. Press OK. This will close the dialog.
Continue with the conversion process. If you look at your newly formed .int files, you will see the line:
DATABASE_SPACE_NAME YourDatabaseName
Now, one more change in the .src file of your program. Somewhere towards the top of your code (for example, in the oApplication object) add the line
Login “YOURSERVERYOURINSTANCE” “UserName” “Password” “FLEX2SQL_DRV”
See the Login command in the DataFlex help files for more details on the Login command. The top of the Orders.src file would look like (in this case the login is connecting to an MSSQL server using the trusted connection):
Use OrderPrecompile.pkg
Use DfAllent.pkg
Use cCJStandardCommandBarSystem.pkg
Use cToolTipController.pkg
Use cCJCommandBarSystem.pkg
Object oHtmlHelp is a cHtmlHelp
End_Object
Object oApplication is a cApplication
Set psCompany to "Data Access Worldwide"
Set psProduct to "DataFlex Examples"
Set psVersion to "19.1"
Set psProgram to "Order"
Set psHelpFile to "DevelopmentGuide.chm"
Set peHelpType to htHtmlHelp
Login "localhost\MSSQLServer" "" "" "SQL_DRV"
Object oConnection is a cConnection
Use LoginEncryption.pkg
Use DatabaseLoginDialog.dg
End_Object
End_Object
Senario #2: Use both Dataflex and Flex2SQL commands¶
After using Flex2SQL Utility Classic to convert your data, we want to login into the server and set the database using the Flex2SQL Classic command Set_Database_Name. To use the Flex2SQL Classic command we have to add the Mertech.inc file. So first we try
- ::
Use OrderPrecompile.pkg Use DfAllent.pkg Use cCJStandardCommandBarSystem.pkg Use cToolTipController.pkg Use cCJCommandBarSystem.pkg use Mertech.inc
Object oHtmlHelp is a cHtmlHelp End_Object
- Object oApplication is a cApplication
Set psCompany to “Data Access Worldwide” Set psProduct to “DataFlex Examples” Set psVersion to “20.0” Set psProgram to “Order” Set psHelpFile to “DevelopmentGuide.chm” Set peHelpType to htHtmlHelp
- Object oConnection is a cConnection
Use LoginEncryption.pkg Use DatabaseLoginDialog.dg
//login to the server and set the database Login “MYSERVERMYINSTANCE” “” “” “SQL_DRV” //set the database name Set_Database_Name to “ClassicEd”
End_Object
End_Object
When we try to compile, there are many, many errors. There are 3 spots we need to fix. 1) At the very top of the file, insert the following:
Use mertech.inc
Define cConnection for UI
Define cConnection.pkg for UI
Define sql.pkg for UI
Define sql for UI
2) The oConnection object in oApplication must be either removed or commented out:
Object oApplication is a cApplication
Set psCompany to "Data Access Worldwide"
Set psProduct to "DataFlex Examples"
Set psVersion to "19.1"
Set psProgram to "Order"
Set psHelpFile to "DevelopmentGuide.chm"
Set peHelpType to htHtmlHelp
// Object oConnection is a cConnection
// Use LoginEncryption.pkg
// Use DatabaseLoginDialog.dg
// End_Object
//login to the server and set the database
Login "WIN11DEV\MDSEXPRESS" "" "" "SQL_DRV"
//set the database name
Set_Database_Name to "ClassicEd"
End_Object
3) Finally, the StdAbout.pkg and the call to Activate_About (in the Client_Area) must also be commented out:
Object oClientArea is a ClientArea
Use Customer.vw
Use Inventory.vw
Use Order.vw
Use SalesPerson.vw
Use Vendor.vw
// Use StdAbout.pkg
// Procedure Activate_About
// Send DoAbout "Order Entry Sample Application" "19.1.0.0" "Copyright (c) 2021 Data Access Corporation" "Data Access Worldwide" ""
// End_Procedure
End_Object
So our final, compilable code will look like:
::
Use mertech.inc
Define cConnection for UI
Define cConnection.pkg for UI
Define sql.pkg for UI
Define sql for UI
Use OrderPrecompile.pkg
Use DfAllent.pkg
Use cCJStandardCommandBarSystem.pkg
Use cToolTipController.pkg
Use cCJCommandBarSystem.pkg
Object oHtmlHelp is a cHtmlHelp
End_Object
Object oApplication is a cApplication
Set psCompany to "Data Access Worldwide"
Set psProduct to "DataFlex Examples"
Set psVersion to "20.0"
Set psProgram to "Order"
Set psHelpFile to "DevelopmentGuide.chm"
Set peHelpType to htHtmlHelp
//Object oConnection is a cConnection
// Use LoginEncryption.pkg
// Use DatabaseLoginDialog.dg
//End_Object
//login to the server and set the database
Login "MYSERVER\MYINSTANCE" "" "" "SQL_DRV"
//set the database name
Set_Database_Name to "ClassicEd"
End_Object
Object oToolTipController is a cToolTipController
Move Self to ghoToolTipController
End_Object
Use oEditContextMenu.pkg
Use oDEOEditContextMenu17.pkg
Object oMain is a Panel
Set Label to "Order Entry Sample Application"
Set Location to 4 3
Set Size to 300 450
....menu code here......
Object oClientArea is a ClientArea
Use Customer.vw
Use Inventory.vw
Use Order.vw
Use SalesPerson.vw
Use Vendor.vw
//Use StdAbout.pkg
//Procedure Activate_About
// Send DoAbout "Order Entry Sample Application" "19.1" "Copyright (c) 2021 Data Access Corporation" "Data Access Worldwide" ""
//End_Procedure
End_Object
End_Object
Start_UI
Now all should compile and run.