Skip to main content
All docs
V25.1
  • TdxReportDatabaseSQLConnection Class

    A component designed to fetch data from an SQL database (SQL Server, PostgreSQL, SQLite, etc.).

    Declaration

    TdxReportDatabaseSQLConnection = class(
        TdxReportCustomDataConnection
    )

    Remarks

    A data connection component allows you to bind a TdxReport component to data.

    Main API Members

    The list below outlines key members of the TdxReportDatabaseSQLConnection class. These members allow you to configure data connection settings.

    Data Connection Settings

    Active
    Specifies if the data connection is active.
    DisplayName

    Specifies the data connection’s name in both Report Designer and Collection Editor dialogs.

    The DisplayName property value is used to refer to the data connection in the report template.

    ConnectionString

    Specifies a connection string.

    Tip

    The TdxReportDatabaseSQLConnection component relies on our ASP.NET Core Reporting engine (based on the XPO ORM powered by ADO.NET). Refer to the following topic for connection string examples: Specify a Connection String.

    General-Purpose API Members

    Collection | Index
    Specify the parent collection component.

    Code Example: Connect to an SQL Database and Edit Report Templates

    The following code example uses the TdxReportDatabaseSQLConnection component to connect to a demo database (nwind.mdb), displays the Report Designer dialog, and saves all changes made to the UserReport.repx file:

    uses
      dxReport,  // Declares the TdxReport component and related types
      dxReport.ConnectionString.SQL;  // Declares the TdxReportDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.Button1Click(Sender: TObject);
    var
      ADataConnection: TdxReportDatabaseSQLConnection;
      AReport: TdxReport;
    begin
      ADataConnection := TdxReportDatabaseSQLConnection.Create(Self);
      try
        ADataConnection.Name := 'DataConnection';
        // Specify a connection string required to connect to a demo database (nwind.mdb)
        ADataConnection.ConnectionString := 'XpoProvider=MSAccess;Provider=Microsoft.ACE.OLEDB.12.0;' +
          'Data Source=C:\Users\Public\Documents\DevExpress VCL Demos\' +
          'MegaDemos\Product Demos\ExpressPivotGrid\Data\nwind.mdb';
        AReport := TdxReport.Create(Self);
        try
          AReport.ShowDesigner;  // Displays the Web-based Report Designer dialog
          AReport.Layout.SaveToFile('UserReport.repx');  // Saves the report template state to a file
        finally
          AReport.Free;
        end;
      finally
        ADataConnection.Free;
      end;
    end;
    

    Indirect TdxReportDatabaseSQLConnection Class References

    The following public API members reference the TdxReportDatabaseSQLConnection class as a TdxReportCustomDataConnection object:

    TdxReportDataConnectionCollection.Add
    Creates a data connection of the required type and adds the connection to the collection.
    TdxReportDataConnectionCollection.Items
    Provides indexed access to all data connection components stored in the collection.
    TdxReportDataConnectionManager.Items
    Provides indexed access to stored data connection components.

    Other Report Data Connection Components

    TdxReportInMemoryJSONConnection
    A component designed for interaction with data stored in memory.
    TdxReportDataSetJSONConnection
    A component designed to fetch data from one or multiple datasets (TDataSet descendant instances).
    See Also