Back to Devexpress

SqlDataSource.Result Property

corelibraries-devexpress-dot-dataaccess-dot-sql-dot-sqldatasource-0cb11b14.md

latest3.8 KB
Original Source

SqlDataSource.Result Property

Gets a collection of tables and their relations from the current SqlDataSource.

Namespace : DevExpress.DataAccess.Sql

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
[Browsable(false)]
public IResultSet Result { get; }
vb
<Browsable(False)>
Public ReadOnly Property Result As IResultSet

Property Value

TypeDescription
IResultSet

An object implementing the IResultSet interface that is the collection of tables and their relations from the current SqlDataSource.

|

Remarks

The Result property provides access to the collection of data tables and their relations from the current SqlDataSource. For each table, you can access columns and rows belonging to this table.

Note that for the inherited DashboardSqlDataSource class, the Result property does not return any data. The Dashboard control reads data internally.

Note

Note that the Result property is initialized after the SqlDataSource is filled (for instance, using the SqlDataSource.Fill method).

Example

The following example illustrates how to use the SqlDataSource.Result property to extract all data records from an SqlDataSource and pass them to a corresponding DataTable object.

csharp
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Sql.DataApi;
using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;
// ...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();
    SqlDataSource ds = report.DataSource as SqlDataSource;

    ds.Fill();
    ITable src = ds.Result["Categories"];
    DataTable dest = new DataTable("Categories");
    foreach (IColumn column in src.Columns)
        dest.Columns.Add(column.Name, column.Type);
    foreach (IRow row in src)
        dest.Rows.Add(row.ToArray());
}
vb
Imports DevExpress.DataAccess.Sql
Imports DevExpress.DataAccess.Sql.DataApi
Imports System
Imports System.Data
Imports System.Linq
Imports System.Windows.Forms
' ...

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim report As New XtraReport1()
    Dim ds As SqlDataSource = TryCast(report.DataSource, SqlDataSource)

    ds.Fill()
    Dim src As ITable = ds.Result("Categories")
    Dim dest As New DataTable("Categories")
    For Each column As IColumn In src.Columns
        dest.Columns.Add(column.Name, column.Type)
    Next column
    For Each row As IRow In src
        dest.Rows.Add(row.ToArray())
    Next row
End Sub

See Also

SqlDataSource Class

SqlDataSource Members

DevExpress.DataAccess.Sql Namespace