Using Managed Connections
Introduction
The DataFlex SQL Drivers support the use of Connection IDs to make it easier to store database server strings in a central location. The cConnection class integrates Connection ID support into the framework. The Studio and other DataFlex tools generate, maintain, and use Connection IDs.
cConnection and Connection IDs
DataFlex has a cConnection class, which handles connections for drivers that support Connection IDs. We refer to this as using Managed Connections. Basically, this class, which is represented as a single global object, allows you to:
- Add Connection ID / Connection String pairs
- Use those Connection IDs in your table INT files
- Login to database servers via Connection IDs
- Make Embedded SQL (ESQL) connections to servers via Connection IDs
The cConnection class provides a complete interface, which includes:
- Adding/removing/editing connections
- Login/Logout via Connection IDs
- Handling encrypted credentials (i.e., user names and encrypted passwords)
- Dynamic switching of connection string definitions while an application is running
- Providing a simple high-level interface for basic usage
- Providing a complete lower-level interface for advanced usage
- Integration with the
cApplicationclass to further simplify high-level coding - Providing a more standard approach for dealing with SQL, where you:
- Define a server/database connection
- Login to an SQL server and database
- Open and access tables in that database
Managed Connections are fully supported in the Studio (and the other DataFlex tools) and are fully integrated into the DataFlex framework, and therefore your applications. Managed Connections greatly simplify deployment because server/database connections are defined and configured in a central location.
Login Credentials for Managed Connections in Web Applications
Windows Applications, by default, include a connection dialog (included via "Use DatabaseLoginDialog.dg"). Since Web Applications cannot display Windows dialogs and the DataFlex Web Application Service typically uses a different Windows user ID than your Studio developer Windows user ID, especially when deploying an application, we have added a Windows application template in the Studio under File > Create New > Project named "Managed Connection Login Project". This creates a small Windows application that allows you to set the credentials for Managed Applications. Once it has been run, you can then run a Web Application in the same workspace to use those credentials.