corelibraries-403633-devexpress-data-library-data-sources-use-the-sql-data-source.md
The SqlDataSource component is a read-only source to access SQL databases. It supports multiple database engines, which are listed in the following help topic: Supported Data Providers.
You can add the SQLDataSource component to your WinForms application in the Visual Studio Designer.
Locate the SqlDataSource component in the DX.25.2: Data & Analytics Toolbox section and drop it onto the form:
After you add a component to the form, the Data Source Wizard is invoked automatically. Follow the Wizard pages to set up a connection.
Expand the SqlDataSource smart tag to adjust the data source settings:
The following commands are available:
Configure Connection Invokes the Connection Editor Wizard. The command is equivalent to the SqlDataSourceUIHelper.ConfigureConnection method.Manage Queries Invokes the Query Builder that allows you to manage the collection of queries. The collection is accessible from the SqlDataSource.Queries property.Manage Relations
This command is available when there are two or more queries in the collection. The command invokes the Master-Detail Relation Editor that allows you to specify data table relations:
Use the SqlDataSource.Relations property to access the relations.
Rebuild Result Schema This command calls the SqlDataSource.RebuildResultSchema method, which updates the result schema on the client side after the query is executed. This command does not affect the actual database schema on the server. When an XtraReport is bound to SqlDataSource , call the RebuildResultSchema method to update the Field List in the Report Designer.Request Database Schema This command calls the SqlDataConnection.GetDBSchema method, which retrieves the database schema from the server.
Tip
Use the SqlDataSourceUIHelper class methods to invoke the dialogs that allow the user to configure conections, manage queries, and specify table relations. Ensure that your application references the DevExpress.DataAccess.v25.2.UI.dll assembly.
Call the Fill or FillAsync method to populate the data source. When the SqlDataSource is bound to the XtraReport descendant, this method call is not necessary, because the report populates the data source before document generation starts. However, if a data source does not support schema-only mode, the Fill/FillAsync call is required.
To create the SqlDataSource component and configure it at runtime, do the following: