Alpha Software 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.

Alpha Software

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.

Alpha Software

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.

Alpha Software

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”.

Alpha Software

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

Alpha Software

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.

Alpha Software

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.

Alpha Software

“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.

Alpha Software

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

Alpha Software

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.

Alpha Software

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.

Alpha Software

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.

Alpha Software

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| {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.

Alpha SoftwareA 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:

Alpha Software

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

Alpha Software

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.

Alpha Software

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.

Alpha Software

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.

Alpha Software

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.

Alpha Software

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.
Prev Post Image
Internet Failure: Why You Need to Build Offline Capabilities Into Apps
Next Post Image
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
Manufacturing Data Collection Systems: Manufacturing Efficiency and Productivity In The Fourth Industrial Revolution
Manufacturing Data Collection Systems: Manufacturing Efficiency and Productivity In The Fourth Industrial Revolution
New Webinar: How to Integrate ChatGPT with Alpha Anywhere
New Webinar: How to Integrate ChatGPT with Alpha Anywhere
Best Data Collection Software For Manufacturing [2024]: A 101 Guide
Best Data Collection Software For Manufacturing [2024]: A 101 Guide

The Alpha platform is the only unified mobile and web app development and deployment environment with distinct “no-code” and “low-code” components. Using the Alpha TransForm no-code product, business users and developers can take full advantage of all the capabilities of the smartphone to turn any form into a mobile app in minutes, and power users can add advanced app functionality with Alpha TransForm's built-in programming language. IT developers can use the Alpha Anywhere low-code environment to develop complex web or mobile business apps from scratch, integrate data with existing systems of record and workflows (including data collected via Alpha TransForm), and add additional security or authentication requirements to protect corporate data.