[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Collapse]Cross-Platform Core Libraries
  Core Library Assemblies
 [Expand]DevExpress Data Library
 [Expand]DevExpress Pivot Grid Core Library
 [Expand]Miscellaneous
 [Collapse]API Reference
  [Expand]DevExpress.Data
  [Expand]DevExpress.Data.Browsing
  [Expand]DevExpress.Data.Browsing.Design
  [Expand]DevExpress.Data.Camera
  [Expand]DevExpress.Data.Controls
  [Expand]DevExpress.Data.Controls.ExpressionEditor
  [Expand]DevExpress.Data.Entity
  [Expand]DevExpress.Data.Filtering
  [Expand]DevExpress.Data.Filtering.Exceptions
  [Expand]DevExpress.Data.Filtering.Helpers
  [Expand]DevExpress.Data.Linq
  [Expand]DevExpress.Data.ODataLinq
  [Expand]DevExpress.Data.PivotGrid
  [Expand]DevExpress.Data.PLinq
  [Expand]DevExpress.Data.TreeList
  [Expand]DevExpress.Data.Utils
  [Expand]DevExpress.Data.Utils.ServiceModel
  [Expand]DevExpress.Data.WcfLinq
  [Expand]DevExpress.Data.WizardFramework
  [Expand]DevExpress.Data.XtraReports.DataProviders
  [Expand]DevExpress.Data.XtraReports.Labels
  [Expand]DevExpress.Data.XtraReports.ServiceModel
  [Expand]DevExpress.Data.XtraReports.ServiceModel.DataContracts
  [Expand]DevExpress.Data.XtraReports.Wizard
  [Expand]DevExpress.Data.XtraReports.Wizard.Presenters
  [Expand]DevExpress.Data.XtraReports.Wizard.Views
  [Expand]DevExpress.DataAccess
  [Expand]DevExpress.DataAccess.ConnectionParameters
  [Expand]DevExpress.DataAccess.DataFederation
  [Expand]DevExpress.DataAccess.EntityFramework
  [Expand]DevExpress.DataAccess.Excel
  [Expand]DevExpress.DataAccess.ExpressionEditor
  [Expand]DevExpress.DataAccess.Json
  [Expand]DevExpress.DataAccess.Localization
  [Expand]DevExpress.DataAccess.ObjectBinding
  [Collapse]DevExpress.DataAccess.Sql
   [Expand]AggregateQueryInvalidSortingValidationException Class
    AggregationType Enumeration
   [Expand]AggregationWithoutAliasValidationException Class
   [Expand]AliasedBase Class
   [Expand]AllColumns Class
   [Expand]CircularRelationsValidationException Class
   [Expand]Column Class
   [Expand]ColumnBase Class
   [Expand]ColumnExpression Class
   [Expand]ColumnInfo Class
   [Expand]ColumnNotInSchemaValidationException Class
   [Expand]ColumnNullValidationException Class
    ConditionType Enumeration
   [Expand]ConfigureDataConnectionEventArgs Class
    ConfigureDataConnectionEventHandler Delegate
   [Expand]ConnectionErrorEventArgs Class
    ConnectionErrorEventHandler Delegate
   [Expand]ConnectionOptions Class
   [Expand]CustomExpression Class
   [Expand]CustomExpressionWithAmbiguousColumnValidationException Class
   [Expand]CustomExpressionWithColumnOfMissingTableValidationException Class
   [Expand]CustomExpressionWithMissingInSchemaColumnValidationException Class
   [Expand]CustomizeFilterExpressionEventArgs Class
    CustomizeFilterExpressionEventHandler Delegate
   [Expand]CustomSqlQuery Class
   [Expand]CustomSqlQueryValidationException Class
   [Expand]DatabaseConnectionException Class
   [Expand]DBSchema Class
   [Expand]DBSchemaProviderEx Class
   [Expand]DuplicatingColumnNamesValidationException Class
   [Expand]DuplicatingTableNamesValidationException Class
   [Expand]ExpressionBase Class
   [Expand]ExpressionNullValidationException Class
   [Expand]ExpressionStringNullValidationException Class
   [Expand]FilterByAmbiguousColumnValidationException Class
   [Expand]FilterByColumnOfMissingTableValidationException Class
   [Expand]FilterByMissingInSchemaColumnValidationException Class
   [Expand]Group Class
   [Expand]GroupByAggregateColumnValidationException Class
   [Expand]GroupByWithoutAggregateValidationException Class
   [Expand]GroupingInfo Class
   [Expand]GroupingInfoList Class
   [Expand]GroupNullValidationException Class
   [Expand]HavingWithoutGroupByValidationException Class
   [Expand]IDBSchemaProvider Interface
   [Expand]IDBSchemaProviderEx Interface
   [Expand]IncompleteRelationValidationException Class
   [Expand]InvalidExpressionStringValidationException Class
   [Expand]IResultSchemaProvider Interface
   [Expand]Join Class
   [Expand]MasterDetailInfo Class
   [Expand]MasterDetailInfoCollection Class
   [Expand]NegativeTopSkipValidationException Class
   [Expand]NoColumnsValidationException Class
   [Expand]NoRelationColumnsValidationException Class
   [Expand]NoTablesValidationException Class
   [Expand]PartialAggregationValidationException Class
   [Expand]QueryExecutionException Class
   [Expand]QueryParameter Class
   [Expand]RecordsCount Class
   [Expand]RelationColumnInfo Class
   [Expand]RelationColumnNotInSchemaValidationException Class
   [Expand]RelationColumnNullValidationException Class
   [Expand]RelationException Class
   [Expand]RelationInfo Class
   [Expand]RelationInfoList Class
   [Expand]RelationNullValidationException Class
   [Expand]RelationTableNotSelectedValidationException Class
   [Expand]ResultSchemaProvider Class
    SchemaLoadingMode Enumeration
   [Expand]SelectQuery Class
   [Expand]SelectQueryFluentBuilder Class
   [Expand]SkipWithoutSortingValidationException Class
   [Expand]SortByAggregateColumnValidationException Class
   [Expand]Sorting Class
   [Expand]SortingBySameColumnTwiceValidationException Class
   [Expand]SortingInfo Class
   [Expand]SortingInfoList Class
   [Expand]SortingNullValidationException Class
   [Expand]SqlDataConnection Class
   [Collapse]SqlDataSource Class
     SqlDataSource Members
    [Expand]SqlDataSource Constructor
    [Expand]SqlDataSource Properties
    [Expand]SqlDataSource Events
    [Expand]SqlDataSource Methods
   [Expand]SqlQuery Class
   [Expand]SqlQueryCollection Class
   [Expand]SqlStringEmptyValidationException Class
   [Expand]StoredProcNameNullValidationException Class
   [Expand]StoredProcNotInSchemaValidationException Class
   [Expand]StoredProcParamCountValidationException Class
   [Expand]StoredProcParamNameValidationException Class
   [Expand]StoredProcParamNullValidationException Class
   [Expand]StoredProcParamTypeValidationException Class
   [Expand]StoredProcQuery Class
   [Expand]Table Class
   [Expand]TableInfo Class
   [Expand]TableInfoList Class
   [Expand]TableNotInSchemaValidationException Class
   [Expand]TableNotSelectedValidationException Class
   [Expand]TableNullValidationException Class
   [Expand]TableQuery Class
   [Expand]TablesNotRelatedValidationException Class
   [Expand]UnnamedColumnValidationException Class
   [Expand]UnnamedTableValidationException Class
   [Expand]ValidationException Class
  [Expand]DevExpress.DataAccess.Sql.DataApi
  [Expand]DevExpress.DataAccess.UI
  [Expand]DevExpress.DataAccess.UI.Design
  [Expand]DevExpress.DataAccess.UI.EntityFramework
  [Expand]DevExpress.DataAccess.UI.Excel
  [Expand]DevExpress.DataAccess.UI.Localization
  [Expand]DevExpress.DataAccess.UI.ObjectBinding
  [Expand]DevExpress.DataAccess.UI.Sql
  [Expand]DevExpress.DataAccess.UI.Wizard
  [Expand]DevExpress.DataAccess.UI.Wizard.Services
  [Expand]DevExpress.DataAccess.UI.Wizard.Views
  [Expand]DevExpress.DataAccess.Web
  [Expand]DevExpress.DataAccess.Wizard
  [Expand]DevExpress.DataAccess.Wizard.Model
  [Expand]DevExpress.DataAccess.Wizard.Presenters
  [Expand]DevExpress.DataAccess.Wizard.Services
  [Expand]DevExpress.DataAccess.Wizard.Views
  [Expand]DevExpress.Diagram.Core
  [Expand]DevExpress.Diagram.Core.Layout
  [Expand]DevExpress.Diagram.Core.Localization
  [Expand]DevExpress.Diagram.Core.Shapes
  [Expand]DevExpress.Diagram.Core.Themes
  [Expand]DevExpress.DocumentServices.ServiceModel
  [Expand]DevExpress.DocumentServices.ServiceModel.Client
  [Expand]DevExpress.DocumentServices.ServiceModel.DataContracts
  [Expand]DevExpress.DocumentView
  [Expand]DevExpress.Entity.Model
  [Expand]DevExpress.Entity.ProjectModel
  [Expand]DevExpress.Export
  [Expand]DevExpress.Export.Xl
  [Expand]DevExpress.Map
  [Expand]DevExpress.Mvvm
  [Expand]DevExpress.Mvvm.DataAnnotations
  [Expand]DevExpress.Mvvm.DataModel
  [Expand]DevExpress.Mvvm.Gantt
  [Expand]DevExpress.Mvvm.ModuleInjection
  [Expand]DevExpress.Mvvm.UI
  [Expand]DevExpress.Mvvm.Utils
  [Expand]DevExpress.Mvvm.ViewModel
  [Expand]DevExpress.Office.Crypto
  [Expand]DevExpress.PivotGrid.Printing
  [Expand]DevExpress.Printing
  [Expand]DevExpress.Printing.Core
  [Expand]DevExpress.Printing.ExportHelpers
  [Expand]DevExpress.ReportServer.Printing
  [Expand]DevExpress.ReportServer.Printing.Services
  [Expand]DevExpress.ReportServer.ServiceModel.Client
  [Expand]DevExpress.ReportServer.ServiceModel.ConnectionProviders
  [Expand]DevExpress.ReportServer.ServiceModel.DataContracts
  [Expand]DevExpress.Schedule
  [Expand]DevExpress.Security.Resources
  [Expand]DevExpress.Services
  [Expand]DevExpress.Sparkline
  [Expand]DevExpress.TreeMap
  [Expand]DevExpress.Utils
  [Expand]DevExpress.Utils.Commands
  [Expand]DevExpress.Utils.Controls
  [Expand]DevExpress.Utils.Filtering.Internal
  [Expand]DevExpress.Utils.IoC
  [Expand]DevExpress.Utils.Localization
  [Expand]DevExpress.Utils.Serializing.Helpers
  [Expand]DevExpress.Utils.Svg
  [Expand]DevExpress.WebUtils
  [Expand]DevExpress.Xpf.Core
  [Expand]DevExpress.Xpf.Printing
  [Expand]DevExpress.Xpo
  [Expand]DevExpress.Xpo.DB
  [Expand]DevExpress.Xpo.DB.Exceptions
  [Expand]DevExpress.Xpo.DB.Helpers
  [Expand]DevExpress.Xpo.Helpers
  [Expand]DevExpress.XtraCharts
  [Expand]DevExpress.XtraCharts.Localization
  [Expand]DevExpress.XtraCharts.Native
  [Expand]DevExpress.XtraCharts.Printing
  [Expand]DevExpress.XtraEditors
  [Expand]DevExpress.XtraEditors.DXErrorProvider
  [Expand]DevExpress.XtraExport.Csv
  [Expand]DevExpress.XtraGauges.Base
  [Expand]DevExpress.XtraGauges.Core
  [Expand]DevExpress.XtraGauges.Core.Base
  [Expand]DevExpress.XtraGauges.Core.Drawing
  [Expand]DevExpress.XtraGauges.Core.Localization
  [Expand]DevExpress.XtraGauges.Core.Model
  [Expand]DevExpress.XtraGauges.Core.Primitive
  [Expand]DevExpress.XtraGrid
  [Expand]DevExpress.XtraPivotGrid
  [Expand]DevExpress.XtraPivotGrid.Customization
  [Expand]DevExpress.XtraPivotGrid.Data
  [Expand]DevExpress.XtraPivotGrid.Localization
  [Expand]DevExpress.XtraPivotGrid.Selection
  [Expand]DevExpress.XtraPrinting
  [Expand]DevExpress.XtraPrinting.BarCode
  [Expand]DevExpress.XtraPrinting.Caching
  [Expand]DevExpress.XtraPrinting.DataNodes
  [Expand]DevExpress.XtraPrinting.Drawing
  [Expand]DevExpress.XtraPrinting.Export
  [Expand]DevExpress.XtraPrinting.Export.Web
  [Expand]DevExpress.XtraPrinting.Localization
  [Expand]DevExpress.XtraPrinting.Native
  [Expand]DevExpress.XtraPrinting.Shape
  [Expand]DevExpress.XtraPrinting.Shape.Native
  [Expand]DevExpress.XtraPrinting.WebClientUIControl.DataContracts
  [Expand]DevExpress.XtraPrinting.XamlExport
  [Expand]DevExpress.XtraPrintingLinks
  [Expand]DevExpress.XtraReports
  [Expand]DevExpress.XtraReports.Design
  [Expand]DevExpress.XtraReports.Expressions
  [Expand]DevExpress.XtraReports.Parameters
  [Expand]DevExpress.XtraReports.ReportGeneration
  [Expand]DevExpress.XtraReports.UI
  [Expand]DevExpress.XtraScheduler
  [Expand]DevExpress.XtraScheduler.Compatibility
  [Expand]DevExpress.XtraScheduler.Drawing
  [Expand]DevExpress.XtraScheduler.Exchange
  [Expand]DevExpress.XtraScheduler.iCalendar
  [Expand]DevExpress.XtraScheduler.iCalendar.Components
  [Expand]DevExpress.XtraScheduler.Localization
  [Expand]DevExpress.XtraScheduler.Native
  [Expand]DevExpress.XtraScheduler.Outlook
  [Expand]DevExpress.XtraScheduler.Outlook.Interop
  [Expand]DevExpress.XtraScheduler.Reporting
  [Expand]DevExpress.XtraScheduler.Services
  [Expand]DevExpress.XtraScheduler.Services.Implementation
  [Expand]DevExpress.XtraScheduler.Tools
  [Expand]DevExpress.XtraScheduler.UI
  [Expand]DevExpress.XtraScheduler.Xml
  [Expand]DevExpress.XtraSpellChecker
  [Expand]DevExpress.XtraSpellChecker.Rules
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

SqlDataSource Class

The data source that allows you to bind Windows Forms data-aware controls to a database (in read-only mode) using specified data connection options.

Namespace:DevExpress.DataAccess.Sql
Assembly:DevExpress.DataAccess.v19.2.dll

Expanded Syntax

Expanded Remarks

Expanded Design-Time

The SQLDataSource component is automatically added when you run a Data Source Wizard to provide database access to DevExpress WinForms data-aware controls, reports and dashboards.

Do the following to add the SQLDataSource component manually:

  1. Locate the SqlDataSource component on the toolbox (the 'Data and Analytics' tab) and drop it onto the form.

  2. After the component is dropped, the Data Source Wizard appears. Go through the Wizard pages to set up the connection.

If you need to modify the data source later, you can use the SqlDataSource's smart-tag.

The following commands are available:

  • Configure Connection...

    Corresponds to the ConfigureDataConnection method that invokes the Connection Editor.

  • Manage Queries...

    Corresponds to the Queries property that is used to access the collection of queries. The following image illustrates the Manage Queries dialog.

  • Manage Relations...

    Corresponds to the Relations property that is used to access the collection of data relations.

    This command is available when there are two or more queries in the collection.

    The following image illustrates the Master-Detail Relation Editor.

  • Rebuild Result Schema

    Corresponds to the RebuildResultSchema method that updates the result schema available on the client after query execution (it can be accessed using the Result property). This command does not affect the actual database schema on the server.

    When using a SqlDataSource to bind an DevExpress.XtraReports.UI.XtraReport to data, call the RebuildResultSchema method to make the data source structure displayed in the Field List of an End-User Report Designer. For a code sample, see Bind a Report to a Microsoft SQL Server Database (Runtime Sample).

  • Request Database Schema

    Corresponds to the SqlDataConnection.GetDBSchema method that returns the schema of the database from the server and updates the result schema on the client.

Note

Certain controls (e.g., the DevExpress.XtraGrid.GridControl) do not automatically retrieve data when bound to the SqlDataSource component, and require calling the Fill method manually. See the Binding to SQL Data topic for an example.

When using a SqlDataSource to bind an DevExpress.XtraReports.UI.XtraReport to data, the Fill method is called internally when a report document is generated by using the DevExpress.XtraReports.UI.XtraReport.CreateDocument or IReportPrintTool.ShowPreview method.

Expanded Runtime Specifics

To configure a data connection in code, you can use the methods of the DevExpress.DataAccess.UI.Sql.SqlDataSourceUIHelper class (requires referencing the DevExpress.DataAccess.v19.2.UI.dll assembly to an application).

Expanded Supported Data Providers

The SqlDataSource component supports the following data providers:

Relational Database System

Supported Versions

.NET Framework Data Provider

.NET Standard 2.0 Data Provider

Microsoft SQL Server

2005 or higher

2005 Express or higher

Azure SQL Database

System.Data.SqlClient.dll

System.Data.dll (Included in .NET Framework)

System.Data.SqlClient.dll

Microsoft Access

Access 2000 or higher

Access 2007 or higher

System.Data.dll (Included in .NET Framework)

 

Microsoft SQL Server CE

3.5, 4.0

System.Data.SqlServerCe.dll (Included in .NET Framework)

 

Oracle Database

9i or higher

Oracle.ManagedDataAccess.dll

System.Data.OracleClient.dll

Oracle.DataAccess.dll

Oracle.ManagedDataAccess.Core.dll

Amazon Redshift

n/a

Npgsql.dll

Npgsql.dll

Google BigQuery

Only legacy SQL functions and operations are supported

DevExpress.DataAccess.BigQuery.dll

DevExpress.DataAccess.BigQuery.dll

Teradata

13.0 or higher

Teradata.Client.Provider.dll

Teradata.Client.Provider.dll

SAP Sybase Advantage

Advantage Database Server 9.1 or higher

Advantage.Data.Provider.dll

 

SAP Sybase ASE

Sybase Adaptive Server 12.0 or higher

Sybase.AdoNet4.AseClient.dll

 

SAP SQL Anywhere

11 or higher

Sap.Data.SQLAnywhere.dll

 

IBM DB2

9.5 or higher

IBM.Data.DB2.dll

IBM.Data.DB2.Core.dll

Firebird

1.5 or higher, Dialect 3

FirebirdSql.Data.FirebirdClient.dll

FirebirdSql.Data.Firebird.dll

FirebirdSql.Data.FirebirdClient.dll

MySQL

4.1 or higher

MySql.Data.dll

MySql.Data.dll

Pervasive PSQL

9.x or higher

Pervasive.Data.SqlClient.dll

 

PostgreSQL

7.x or higher

Npgsql.dll

Npgsql.dll

VistaDB

4, 5

VistaDB.5.NET40.dll

 

SQLite

3.x

System.Data.SQLite.dll

Microsoft.Data.SQLite.dll

System.Data.SQLite.Core.dll

Microsoft.Data.Sqlite.Core.dll

XML file

n/a

Built-in support

Built-in support

When you construct a connection string manually (see CustomStringConnectionParameters), use the XpoProvider parameter to identify the provider type. See connection string examples in the table below.

Relational Database System

Connection String Sample <sup>See Note</sup>

Microsoft SQL Server <sup>*</sup>

XpoProvider=MSSqlServer;Data Source=(local);User ID=username;Password=password;Initial Catalog=database;Persist Security Info=true

<sup>*</sup>The MS SQL Server data provider is automatically specified if you set the "Initial Catalog" parameter and do not use the word "Provider" (for instance, the "XpoProvider" parameter) in the connection string.

Microsoft Access

XpoProvider=MSAccess;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;

XpoProvider=MSAccess;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\mydatabase.accdb;User Id=admin;Password=;

Microsoft SQL Server CE

XpoProvider=MSSqlServerCE;Data Source=MyDatabase.sdf;Password=MyPassword

Oracle Database

XpoProvider=Oracle;Data Source=TORCL;User ID=MyUserName;Password=MyPassword

XpoProvider=ODP;Data Source=TORCL;User ID=MyUserName;Password=MyPassword

XpoProvider=ODPManaged;Data Source=TORCL;User ID=MyUserName;Password=MyPassword

Amazon Redshift

XpoProvider=Amazon Redshift;Server=127.0.0.1;User ID=MyUserName;Password=MyPassword;Database=MyDatabase;Encoding=UNICODE

Google BigQuery

XpoProvider=BigQuery;ProjectID=myProject;DataSetId=myDataSet;OAuthClientId=myClientId;OAuthClientSecret=mySecret;OAuthRefreshToken=myRefreshToken

XpoProvider=BigQuery;ProjectId=project;DatasetId=dataset;ServiceAccountEmail=example@gmail.com;PrivateKeyFileName=key.p12

Teradata

XpoProvider=Teradata;Data Source=myServerAddress;User ID=myUsername;Password=myPassword;

SAP Sybase Advantage

XpoProvider=Advantage;Data Source=\myserver\myvolume\mypat\mydd.add;ServerType=local;User ID=ASSSYS;TrimTrailingSpaces=true

SAP Sybase ASE

XpoProvider=Ase;Port=5000;Data Source=MyAseServer;User ID=MyUserName;Password=MyPassword;Initial Catalog=MyDatabase;Persist Security Info=true

SAP SQL Anywhere

XpoProvider=Asa;eng=server;uid=user;pwd=password;dbn=database;persist security info=true;

IBM DB2

XpoProvider=DB2;Server=server:port;Database=database;UID=user;PWD=password;

Firebird

XpoProvider=Firebird;DataSource=localhost;User=SYSDBA;Password=masterkey;Database=MyDatabase.fdb;ServerType=0;Charset=NONE

MySQL

XpoProvider=MySql;Server=MyServerAddress;User ID=MyUserName;Password=MyPassword;Database=MyDatabase;Persist Security Info= true;Charset=utf8

Pervasive PSQL

XpoProvider=Pervasive;Server=MyServerAddress;UID=MyUserName;PWD=MyPassword;ServerDSN=MyDatabase

PostgreSQL

XpoProvider=Postgres;Server=127.0.0.1;User ID=MyUserName;Password=MyPassword;Database=MyDatabase;Encoding=UNICODE

VistaDB

XpoProvider=VistaDB;Data Source=C:\mydatabase.vdb4

XpoProvider=VistaDB5;Data Source=C:\mydatabase.vdb5

SQLite

XpoProvider=SQLite;Data Source=filename

XML file

XpoProvider=InMemoryDataStore;data source=D:\Contacts.xml;read only=True

Note

The connection strings demonstrated above are examples. You can specify alternative variants.

Expanded Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
       System.ComponentModel.Component
          DevExpress.DataAccess.DataComponentBase
             SqlDataSource

Expanded See Also

Is this topic helpful?​​​​​​​