Skip to main content

DataConnectionBase.Open() Method

Opens the data connection session.

Namespace: DevExpress.DataAccess

Assembly: DevExpress.DataAccess.v22.2.dll

NuGet Package: DevExpress.DataAccess


public void Open()


In this example, the TableQuery.GetSql method is used to obtain the query string that is used to fetch data from the connected data source.

Prior to using this method, open the corresponding data connection by calling the DataConnectionBase.Open method of the SqlDataConnection class.

using System;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraReports.UI;
// ...
        private void XtraReport1_DataSourceDemanded(object sender, EventArgs e) {
            // Create a new SQL data source and specify its connection parameters.
            var sqlDataSource = new SqlDataSource(new Access97ConnectionParameters() {
                FileName = @"..//..//nwind.mdb"

            // Create a query and assign it to the data source.
            SelectQuery query = SelectQueryFluentBuilder
                .SelectColumns("CategoryID", "CategoryName")

            // Open the connection to the data source.

            // Obtain the database schema of the connected data source.
            var sql = query.GetSql(sqlDataSource.Connection.GetDBSchema());

            // Assign the data source to the report.
            this.DataSource = sqlDataSource;
            this.DataMember = "MyQuery";

The following code snippets (auto-collected from DevExpress Examples) contain references to the Open() method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also