DataConnectionBase.Open() Method

Opens the data connection session.

Namespace: DevExpress.DataAccess

Assembly: DevExpress.DataAccess.v20.2.dll


public void Open()
Public Sub 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";
See Also