[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Bind to JSON Data
    Bind to XPO Data
    Bind to Azure SQL Database
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Expand]Behaviors
  [Expand]Application Appearance and Skin Colors
  [Expand]Filtering UI Context
   Find Panel Syntax
  [Expand]Graphics Performance and High DPI
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML-inspired Text Formatting
  [Expand]Menus
  [Expand]Tooltips
  [Expand]Save and Restore Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[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
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Bind to Azure SQL Database

This example illustrates how to bind a GridControl (see GridControl) to an Azure SQL database:

Visit this GitHub page to review and download a complete sample project.

Important

Create a server-level firewall rule for your database to retrieve data from Azure servers.

Expanded Common Implementation Details

Base DataProvider class

All three approaches utilize classes that are derived from the base DataProvider class. This class defines the virtual asynchronous GetDataAsync method whose overrides fetch data from Azure.

Connection Settings

The ConnectionSettings class provides API that retrieves connection details.

Connection credentials and a SQL query that retrieves data from the database are defined in the Main method.

Loading Panel

Binding methods described in this article retrieve data asynchronously, the application UI stays responsive while the application loads database records. To indicate that the data is being loaded, Data Grid shows its loading panel.

Expanded Bind to a DataTable

In this DataProvider descendant, the GetData method override creates a standard System.Data.SqlClient.SqlDataAdapter object that fills a System.Data.DataTable with records.

The DataTable populated with records is then used as a Grid Control's data source.

Expanded DevExpress SqlDataSource component

The following code initializes a new SqlDataSource (see SqlDataSource) that uses a custom query to select data. The query is defined in a separate DXApplication.Data.ConnectionSettings class.

To populate a Grid Control with SqlDataSource data, specify the GridControl.DataMember property and GridControl.DataSource.

Expanded Use an EntityFramework model

To use the EntityFramework, open the NuGet Package Manager ("Project | Manage NuGet Packages...") and install the latest stable Entity Framework 6 package. If you downloaded the sample from GitHub, open this Manager and click "Restore" to re-upload the package.

Declare a System.Data.Entity.DbContext descendant that stores Azure database records.

The GetDataAsync method overrides loads data from the Azure database to a new DbContext instance and imports this data into a new List<Entity> object.

The List with database records is then passed to the Data Grid.

Expanded See Also

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