.daConnections File

The .daConnections file you find in a generated project contains the connection definitions and connection strings, required by Relativity Server or a custom server, to talk to a database.

Previous versions of Data Abstract for Delphi used to store connection definitions in the main executable as embedded resources that were very hard to replace and prevent shipping with your application. While this didn't pose any security threat and was mostly due to how form component streaming works in Delphi, it wasn't optimal.

Newer versions of Data Abstract greatly improves how connection definitions are stored and loaded, and it gives you options to load them from files or from embedded resources without requiring any specific coding.

When you create a new Data Abstract for .NET server, a .daConnections file is created and its properties are set so that it's copied in the directory of the executable, whenever that is built. When you edit your schemas and modify the connection list, the .daConnections file gets modified.

Loading Connections

If you look at the code of the main form of a Data Abstract server you will see the following line of code:

connectionManager.Load();

Similar to the .daConfig file, this line of code tries to load a .daConnection file from two different locations:

  • as a <ApplicationName>.daConnnections file next to your application's executable
  • as a <ApplicationName>.daConnnections resource in your application's executable

This means that if a local file is found next to the executable, that will be loaded first; but if you chose to include a .daConnections resource in your application, your server will work without an external file and use the embedded default connections.

If you want to embed your .daConnections file into your executable, simply click on the .daConnections file in the Solution Explorer and change the property Build Action from None to Embedded Resource in the Properties pane.

Like the Configuration class, the ConnectionManager class also defines a set of Load methods that allow you to load the specific connection file from XML, files or resources.

Structure

The structure of a .daConnections file has been reworked and streamlined since version 3.0, removing any Delphi specific names and class types.

These are the contents of a .daConnections file that is generated when creating a Client and a New Custom Data Abstract Server project is Visual Studio, that connects to the sample PCTrade SQLite database:

<Connections>
  <Definitions>
    <Definition>
      <Description />
      <ConnectionString>SQLite.NET?Server=localhost;Database=C:\Users\Public\Documents\RemObjects Samples\Database\PCTrade.sqlite.db;</ConnectionString>
      <ConnectionType>SQLite</ConnectionType>
      <Default>True</Default>
      <Name>PCTrade-SQLite</Name>
    </Definition>
  </Definitions>
  <CanRaiseEventsInternal>True</CanRaiseEventsInternal>
</Connections>