[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Collapse]Scheduler (legacy)
   [Expand]Overview
   [Collapse]Getting Started
     Lesson 1 - Create an Application using the Template Gallery or Instant Layout Assistant (legacy)
     Lesson 2 - Provide Bar UI for a Scheduler (legacy)
     Lesson 3 - Provide Ribbon UI for a Scheduler (legacy)
     Lesson 4 - Use the DateNavigator Control (legacy)
     Lesson 5 - Bind a Scheduler to Entity Framework Data Source (legacy)
     Lesson 6 - Bind a Scheduler to MS SQL Server Database (legacy)
     Lesson 7 - Create a Custom Edit Appointment Form Using the MVVM Pattern (legacy)
     Lesson 8 - Create a Custom Appointment Recurrence Dialog Using the MVVM Pattern (legacy)
     Lesson 9 - Create a Custom Edit Appointment Form (legacy)
   [Expand]Fundamentals
   [Expand]Visual Elements
   [Expand]Examples
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[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)

Lesson 6 - Bind a Scheduler to MS SQL Server Database (legacy)

Note

You are viewing documentation for the legacy WPF Scheduler control. If you're starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

This lesson demonstrates how to create a simple application with a Scheduler Control using the DevExpress Template Gallery, and bind the scheduler to a Microsoft SQL Server database.

This lesson consists of the following sections.

Expanded Create a Scheduler Application

  1. Click FILE |New | Project... to invoke the New Project dialog. In the invoked dialog, select the DevExpress: Visual C# group, select the DevExpress v18.2 Template Gallery pattern, and click OK.

  2. In the invoked window, select the WPF platform and your preferred language. Then, select the MS Outlook inspired Solution item in the WPF Business Solutions group and click Create Project.

  3. To specify the application theme, click the DXRibbonWindow's smart tag and select the preferred theme from the ApplicationTheme drop-down menu.

  4. To set the ribbon style, click the Ribbon control's smart tag and select the required style from the RibbonStyle drop-down menu.

  5. The result is shown in the image below.

Expanded Create a Database

  1. In the Visual Studio menu, click View | Server Explorer to invoke the Server Explorer pane, and click Connect To Database.

  2. In the invoked window, change the data source to Microsoft SQL Server Database File, set the database name to SchedulerTestDataSet and click OK.

  3. In the Server Explorer, right-click the SchedulerTest database icon and select the New Query item in the context menu.

  4. Copy the following code to the New Query window.

  5. Click the Execute button.

The Appointments and Resources tables are created as a result of query execution.

Expanded Create a Data Source

  1. Click PROJECT | Add New Data Source... to invoke the Data Source Configuration Wizard.

  2. In the invoked window, select the Database source type, then select the Dataset database model.

  3. Next select the SchedulerTest.mdf data connection from the drop-down menu, click Next and then and click YES to copy the local data file to the project and modify the connection.

  4. In the invoked window, select the Appointments and Resources tables, set the dataset name to SchedulerTest and click Finish.

  5. To save appointments created in the application, select the SchedulerTest.mdf file in the Solution Explorer and set its Copy to output Directory to Copy if newer.

Expanded Bind a Scheduler to a Data

In this example, all appointment data is stored in the Appointments data table. This data should be provided to the AppointmentStorage, which is accessed using the SchedulerStorage.AppointmentStorage property. To bind the storage, set the SchedulerControl.Storage.AppointmentStorage.DataSource property to the Appointments data table. Also, in this example, all resources are stored in the Resource data table. This data should be provided to the ResourceStorage, which is accessed using the SchedulerStorage.ResourceStorage property. To bind the storage, set the SchedulerControl.Storage.ResourceStorage.DataSource property to the Resources data table.

You need to populate the underlying AppointmentsDataTable and ResourcesDataTables with data from the database. To do this, use the Fill method of the AppointmentsTableAdapter and ResourcesTableAdapter objects, respectively.

You also need to save changes in the Appointments data table. To do this, handle the SchedulerStorage.AppointmentsChanged, SchedulerStorage.AppointmentsDeleted and SchedulerStorage.AppointmentsInserted events.

Expanded Specify Scheduler Mappings

Specify mappings in the XAML code, as shown below.

Note

To associate an appointment with several resources, set the AppointmentStorage.ResourceSharing property to true. Refer to the Resources for Appointments article to learn more about sharing appointment resources.

Expanded Result

The following image illustrates the running application.

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