Skip to main content
All docs
V25.2
  • TdxBackendDatabaseSQLConnection.ConnectionString Property

    Specifies a connection string.

    Declaration

    property ConnectionString: string read; write;

    Property Value

    Type Description
    string

    A connection string.

    Remarks

    A connection string specifies the database engine type (SQLite, Microsoft SQL Server/Azure SQL, PostgreSQL, Oracle Database, MySQL, Firebird) and all parameters (database host IP, username, password, and so on) required for a connection.

    Assign a valid connection string for a supported SQL database to the ConnectionString and enable the Active property to connect the TdxBackendDatabaseSQLConnection component to the database.

    Code Examples: Connection Strings

    The following code examples demonstrate OnClick handlers that configure a TdxBackendDatabaseSQLConnection component to access different relational databases and to display the Dashboard Designer dialog:

    SQLite

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'SQLite Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=SQLite;' +                         // Specifies the database engine type
        'Data Source=C:\Users\Public\Documents\DevExpress VCL Demos\MegaDemos\' +
        'Product Demos\ExpressReports\Data\devav.sqlite3';
    
      dxBackendDatabaseSQLConnection1.Active := True;   // Connects to the "devav.sqlite3" database
      dxDashboardControl1.ShowDesigner;                 // Displays the "Dashboard Designer" dialog
    end;
    

    Microsoft SQL Server

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'Microsoft SQL Server Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
       'XpoProvider=MSSqlServer;' +   // Specifies the database engine type
       'Data Source=(local);' +       // Specifies the database host
       'User ID=username;' +          // Specifies a valid user name
       'Password=password;' +         // Specifies the corresponding password for the user name
       'Initial Catalog=database;' +  // Specifies the initial catalog for the target database
       'Persist Security Info=true';  // Enables the "Persist Security Info" flag
    
      dxBackendDatabaseSQLConnection1.Active := True;   // Connects to the test database
      dxDashboardControl1.ShowDesigner;                 // Displays the "Dashboard Designer" dialog
    end;
    

    Microsoft SQL Azure

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'Microsoft Azure SQL Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=MSSqlServer;' +         // Specifies the database engine type
        'Data Source=tcp:YourServerName.database.windows.net;' +  // Specifies the database host
        'User Id=azureuser;' +               // Specifies a valid user name
        'Password=password;' +               // Specifies the corresponding password for the user name
        'Initial Catalog=DXApplication384';  // Specifies the initial catalog for the target database
    
      dxBackendDatabaseSQLConnection1.Active := True;   // Connects to the test database
      dxDashboardControl1.ShowDesigner;                 // Displays the "Dashboard Designer" dialog
    end;
    

    MySQL

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'MySQL Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=MySql;' +                      // Specifies the database engine type
        'Server=127.0.0.1;' +                       // Specifies the database server host IP address
        'User ID=MyUserName;' +                     // Specifies a valid user name
        'Password=MyPassword;' +                    // Specifies the corresponding password for the user name
        'Database=MyDatabase;' +                    // Specifies the target database name
        'Persist Security Info=true;Charset=utf8';  // Specifies additional attributes
    
      dxBackendDatabaseSQLConnection1.Active := True; // Connects to the test database
      dxDashboardControl1.ShowDesigner;               // Displays the "Dashboard Designer" dialog
    end;
    

    Oracle

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'Oracle Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=Oracle;' +  // Specifies the database engine type
        'Data Source=TORCL;' +   // Specifies the target database
        'User ID=MyUserName;' +  // Specifies a valid user name
        'Password=MyPassword';   // Specifies the corresponding password for the user name
    
      dxBackendDatabaseSQLConnection1.Active := True; // Connects to the test database
      dxDashboardControl1.ShowDesigner;               // Displays the "Dashboard Designer" dialog
    end;
    

    PostgreSQL

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'PostgreSQL Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=Postgres;' +     // Specifies the database engine type
        'Server=127.0.0.1;' +         // Specifies the database host IP address
        'User ID=myuser;' +           // Specifies a valid user name
        'Password=123;' +             // Specifies the corresponding password for the user name
        'Database=dashboard_test;' +  // Specifies the target database name
        'Encoding=UNICODE';           // Sets UTF-8 as the required encoding
    
      dxBackendDatabaseSQLConnection1.Active := True;   // Connects to the test database
      dxDashboardControl1.ShowDesigner;                 // Displays the "Dashboard Designer" dialog
    end;
    

    Firebird

    uses
      dxDashboard.Control,             // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'Firebird Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=Firebird;' +     // Specifies the database engine type
        'Datasource=localhost;' +     // Specifies the database location (IP 127.0.0.1)
        'User=SYSDBA;' +              // Specifies a valid user name
        'Password=password;' +        // Specifies the corresponding password for the user names
        'Database=C:\Program Files\Firebird\Firebird_5_0\examples\empbuild\EMPLOYEE.FDB;' +
        'ServerType=0;Charset=NONE';  // Specifies additional parameters
    
      dxBackendDatabaseSQLConnection1.Active := True;   // Connects to the EMPLOYEE.FDB database
      dxDashboardControl1.ShowDesigner;                 // Displays the "Dashboard Designer" dialog
    end;
    

    Default Value

    The ConnectionString property’s default value is an empty string.

    See Also