Configuring AlphaDAO Connections When Publishing to a Remote Server

Blog



Configuring AlphaDAO Connections When Publishing to a Remote Server


A project that uses any type of SQL based database will normally use AlphaDAO connection strings. The suggested method is to use named connections. This allows using the name of the connection in every area that requires a connection. The name will then resolve to an actual connection string.

Named connections are initially defined in the development work space and typically point to a local test database. The builder is opened either from the control panel menu, or from any layout that uses an AlphaDAO connection.

The advantage of using a named connection for an AlphaDAO connection is the actual connection string can be changed to point to a different database. All design elements that uses an AlphaDAO connection just use the name and do not need to be edited.



The menu option highlighted for “AlphaDAO Connection Strings” will open the genie to create a named connection. This will show all of the current named connections.



A named connection can be edited or a new one created using the dialog builder.

In many cases, the credentials for the connection are supplied by the owner of the database, such as the Server address or hostname and port, and login credentials for the database. A valid connection will then point to the selected database.



The “Test Connection” button will verify if the connection is valid for the local development workspace.

Deploying to a Remote Server

One of the challenges of publishing an application with connections strings is creating a connection that is appropriate from the server. Since the data server for testing is often a different server than the one used for production or has a different host address, the process requires some planning and information.

The actual connection string used by a project running on an application server must be a connection that will allow the remote application server to access the desired database. The database may be on the same physical server as the application server or accessible from the application server across a local network. In most cases, the database owner can supply the proper credentials and information to connect to the database on that network.

The publish process includes options to assign a different connection string to a named connection that is appropriate from the published location. The publish profile has an option to edit the strings used by the profile. Open the profile that publishes to the desired location and select the option for “Named AlphaDAO connection strings”.



This opens a list of named connections defined in the workspace.



The genie initially uses the default connections string for each named connection, which is the connection string used by the local development system.  This will normally have to be edited by selecting each named connection and clicking the “Edit Connection String” button.



This genie has three options.

“Set to default value” will appear as above and the remote server will attempt to use the same connection as the local development system.  Unless the data server is on the same network as the development system, this would not work in the published environment.

“Copy default value” will place the original connection string in the window where it can be edited manually. This is useful if the change is minor, such as a different file path, or a different server name.



“Build Connection String” will open the same connection string builder used to build the original named connection. This is appropriate when the actual connection string used for the named connection is considerably different that the one used in the local system.

Enter the data supplied by the database owner that will allow access from the remove application server.  Since this server is probably not accessible in the local environment, the data must be typed into each section rather that making a selection from a dropdown control.



The “Test Connection” button will also normally not succeed if the actual database is not accessible.



Select OK, and the connections string genie will now show the actual connection string to use for this named connection when the project is published to the remote server.



Click OK again, and named connections genie will also show the new string.  This will be the actual connections string used when the project is published with this publish profile.


Where is the Data Stored?

When any project is published a file named “A5_application.a5i” is part of the published data. This file contains information about the application and is regenerated and overwritten on every publish.

NOTE: This file should normally not be edited. Any changes may break the application and edits will be overwritten if anything is published to the folder.

The file can be opened in a text editor and examined. The actual connection strings to be used are in a section similar to below.



Each named connection, such as “AlphaSports” has a connection string that was defined in the publish profile. The connection is encrypted for security.

While editing this file is not recommended, it is possible to change the connection strings in the file. The encrypted section can be replaced with a clear text string. The following entries are equivalent.
AlphaSports|Encrypted:3MLNR/D8BLbOLVyV2vnymlT4970fFMs7f75fDdfEcUU7c+AFxa8weZmg7hGupvgz9P8g5meUL/5r66v1hZf1uQRezvAY4EUdPRjXoWAjHVAerGmNkTDVs9QWYpAh8w66VDKPK0kFBnB3fjGD93TsPVXq27CuAI0KGb5Fmr+tzIKsgLqorS63V7E69HtqCmP86V9njOmzCGrCVyy+1CIEEA==
AlphaSports| {A5API='SQLServer',A5DBVersion=2012,Server='SQLProduction',A5ANSINullPadWarn=Default,UserName='MyApplication',Password='ðáóó÷ïòä',Database='MyDatabase'}

Defining a Connection String Directly on the Deployed Server

There is a method to define a connection string directly on the deployed server. This is an advanced technique, but will also verify if any connection is valid.

Depending on how the application is started, there may be a server icon on the Windows system tray.

A running application server will be green, while a stopped server will be red.

If the icon is not found, a second instance of the application server can be opened. This instance will likely start with an error that a port is in use, but the server doesn’t actually have to be running for this operation. The default Windows start menu may look like the following:



After the instance is loaded, right click on the icon to open the application server menu.



Select the “Interactive Window” to open a special window that will allow running code directly on the server.

In the interactive window, type in the code exactly as shown below and hit ENTER.

This will open the same SQL Connections String builder as used to create the original named connections.



A connection can be defined in this builder and any data server that can be reached from this application server can be selected.

If a connection string had previously been defined as part of a publish profile, the string can be pasted into the Connection String window.



Since the builder is running in the same environment as the actual application server, any connections defined should work and connect.

Pressing the “Test Connection” should be successful if the string is valid.



If a connection is successful, this generated connection string can then be copied from the window. The copied connection is proven valid and the original publish profile can be re-edited and this new connection pasted into the “Edit Named Connection” genie from the “Named AlphaDAO connections strings” option for the publish profile.



This new connection string could be added to the “a5_application.a5i” file in the published webroot folder as described in this document. However, since this file is overwritten on every publish, this is not recommended. The correct method is to place the valid connections string in the publish profile definition.
Total Internet Failure: Why You Need to Build Offline Capabilities Into Your Apps
New in Alpha Anywhere: Executing Shell Commands Directly from the Interactive Window

About Author

Default Author Image
Chris Conroy

Chris Conroy runs digital programs for Alpha Software.

Related Posts
6 Reasons why Companies are looking to Build
6 Reasons why Companies are looking to Build "industrial Strength Mobile apps for their "Stand-Up" Staff
Integration between Alpha Anywhere and Microsoft Power BI
Integration between Alpha Anywhere and Microsoft Power BI
How Enterprise Architects Can Drive Digital Transformation
How Enterprise Architects Can Drive Digital Transformation

Comment

Subscribe To Blog

Subscribe to Email Updates