Lesson 7 - Updating Legacy Applications and Conclusion
Even though DataFlex was originally designed around its own, embedded database, it has supported connecting to SQL servers since the early 90s.
Managed connections were introduced in 2017, with the release of DataFlex 19.0. This means there are many applications written over the years that already use SQL servers, but do not benefit from the newer capabilities we’ve seen during this course. In this lesson we’ll see how easy it is to follow these few simple steps…
We’ll migrate the workspace to DataFlex 2022, use the Studio to create a managed connection, update the table intermediate files to use the connection ID, add the cConnection object to the application, compile and run!
- We’re using a Legacy Order Entry example that was developed in Visual DataFlex 17.1 and uses Microsoft SQL Server, but keep in mind that this could be any DataFlex revision and any supported SQL environment.
- The workspace is complete, including the running application, and when we examine the data folder, we can tell this is an SQL application because each table has an intermediate file. The full connection information is present, including the driver, server, connection type, database and table information. As we can see, the same, detailed connection information is duplicated in each table. Even if we wanted to do something as simple as changing the server instance, we’d have to make changes to all the intermediate files. The DataFlex Studio makes it easy to bring the power and flexibility of managed connections to existing applications.
- When we open an older workspace, the migration wizard will walk us through any necessary steps. This example application has already been copied to a new location, so we can safely migrate in place. Note that we don’t have to change anything at this time, a simple compile and run shows the application working the same way as it always has.
- The Start Center indicates that this workspace does not yet have any managed connections defined.
- So we can simply click to bring up the SQL Connection Manager, add a new connection named LegacyOrder, and specify the server, login credentials and database to use.
- At this point, the workspace now has the familiar configuration file with the LegacyOrder id, but all the tables are still using the full connection string.
- We’ll use the SQL Connect/Repair wizard to automatically change all the tables to use the new id. We’ll use the ID we just created and use the Repair Existing option to automatically refresh the intermediate files.
- With just a few clicks, the application is now ready to be compiled and run with managed connections in place!
- But wait, we have a problem! The workspace has the configuration file that contains the id, the table intermediate files have all been set to use it, but the application itself does not know how to use the new capabilities!
- Remember, in Lesson 3 we learned that the cConnection class is where all the magic happens, but we have not yet added an instance in our example. Adding four lines of code inside the cApplication object and recompiling is all it takes to complete the transformation!
- You can see that by creating one or more connections, setting the tables to use them, and adding a few simple lines of code, we can bring the full power and flexibility of managed connections to any application.
We started this course with the premise that using Managed Connections simplifies the development, deployment and support of DataFlex applications that use SQL servers for data management. Together, we’ve seen how they provide a better fit with how data is
accessed in SQL servers, worked with multiple copies of databases and deployed to different servers, all with a few simple changes to workspaces and applications. If you have questions, please go to the Data Access Forums. Thanks for watching, and see you next time!