Show/Hide Toolbars

TMS Aurelius Documentation

Navigation: Database Connectivity

Using the Connection Wizard

Scroll Prev Top Next More

To connect to a database, you need an IDBConnection interface representing the database connection. The easiest way to get one is using the "TMS Aurelius Connection" wizard which is available in Delphi IDE after you installed Aurelius.

 

To create a new connection:

 

1. chose File > New > Other and then look for "TMS Business" category under "Delphi Projects". Then double click "TMS Aurelius Connection".

 

2. Choose between Adapter Mode or Driver Mode.

For Adapter Mode, select the Adapter (component to access database) and the SQL Dialect (type of database server).

For Driver Mode, select Driver to use.

 

3. A new data module will be created with a TAureliusConnection component already preconfigured. If you used the adapter mode, the adapted component will also be created. Either configure the connection settings in the adapted connection (adapter mode) or directly in TAureliusConnection (for driver mode).

 

4. To retrieve a new IDBConnection interface from the data module, just use this code:

 

// The name of data module class might vary from TFireDacMSSQLConnection

// depending on selected driver and SQL Dialect

NewConnection := TFireDacMSSQLConnection.CreateConnection;

 

 

Remarks

 

The wizard shows the following options:

 

For Adapter mode

Adapter: Choose the database component you want to use to connect to the database. You can choose any that is supported by Aurelius component adapters, like FireDac, dbExpress, dbGo (ADO), among others.

 

SQL Dialect: Choose the SQL dialect to be used when executing SQL statements to the database. Some drivers support several dialects (like FireDac for example), and some support just one (for example, SQLite driver only supports SQLite dialect).

 

For Driver mode

Driver: Choose the native database driver you want to use to connect to database, for example "SQLite" or "MSSQL".

 

You can freely configure and try the connection at design-time the usual way you do with your component, that's the purpose of it - to be RAD and working at design-time. It's always a good practice to close the connection once you have tested and configured it, though.

 

The name of the data module is automatically defined by the wizard and it's a combination of the driver and sql dialect you selected. In the example above, it was FireDac driver and MSSQL dialect, but could be different. You can always change this name later.

 

It's important to note that no instance of the data module will be auto-created. Also, the CreateConnection method always create a new instance of the data module, so if you intend to use a single global connection for the application (which is usual for client/server applications), call CreateConnection just once and save the created IDBConnection interface for further use.