Skip to main content
A newer version of this page is available. .

How to: Bind an ASPxScheduler to MS SQL Server Database (Step-by-Step Guide)

  • 5 minutes to read

The following example demonstrates how to bind an ASPxScheduler Control to an MS SQL Server database at design time.

Steps 1-5. Create a Simple Scheduler Project.

  1. Create a new project (ASP.NET Empty Web Application).
  2. Add a Web Form and name it Default.aspx.
  3. Add a new ASP.NET folder to the project - App_Data.
  4. Switch to the Design view and drop the ASPxScheduler control from the Toolbox.

    Drop_Scheduler_Designer

  5. In the Property Grid, specify the width and the DayView scroll height of a Scheduler control. Set the Width to 800px, set the Views->DayView->Styles->ScrollAreaHeight to 600px.

Steps 6-9. Create the Database.

  1. In the Visual Studio menu, select TOOLS->Connect to Database… The Add Connection dialog appears. Click the Change button to invoke the Change Data Source dialog. In the dialog select a Microsoft SQL Server Database File option and click OK.

    ChangeDataSource.png

  2. Select a path for the database file (the App_Data folder) and type a name (Schedule.mdf). Click OK. When you are prompted for creation of a new database, click Yes. The new database is created.

    AddConnection.png

  3. Use the Server Explorer window to select the newly created database, right -click and select New Query in the context menu. This command will open a new window that enables you to execute a database query.
  4. Copy the database SQL script from the Data Table Structure for MS SQL Server Database document. Paste it into the SQL query window and execute the query. The query will create tables for Appointments and Resources within the Schedule database..

Steps 10-16. Create the Appointments Data Source.

  1. Click the smart tag of the ASPxScheduler control in Visual Studio designer to invoke a smart tag panel. In the panel, click the Appointments Data Source combo box and select the New data source… item as shown in the following picture.

    Smart_Tag_New_Datasource

  2. The Data Source Configuration Wizard window is displayed. Follow the wizard to configure the data source. Select the SQL database.

    DataSourceWizard1.png

  3. Next, choose the data connection (the previously created Schedule.mdf database). This database was included in the project at the time it was created, and there are no other data connections in the project.

    DataSourceWizard2.png

  4. Save connection information to the web.config file.

    DataSourceWizard3.png

  5. Select all columns in the Appointments table to include into the data source.

    DataSourceWizard4.png

  6. Click the Advanced button to check the box so that INSERT, UPDATE and DELETE queries will be generated automatically. Click OK to close the dialog.

    DataSourceWizard5.png

  7. Click Next so that you can test the data source. Click Finish, and the Mappings Wizard for Appointments is invoked.

Steps 17-18. Specify Appointment Mappings.

  1. The window of the Mappings Wizard, entitled Setup Appointment Storage, is displayed automatically after you assign an appointment data source for the first time. You can also invoke it any time via the SchedulerControl’s smart tag. To accomplish this, click the smart tag of the ASPxScheduler control in the Visual Studio designer to invoke a smart tag panel. In the panel, click the Mappings Wizard tag under the Appointments Data Source caption. The Mappings Wizard is invoked.
  2. Follow the wizard as described in the Mappings Wizards document to specify appointment mappings.

    Mappings1.png

    Mappings2.png

    The check box in the image above is checked by default and sets the ASPxAppointmentStorage.AutoRetrieveId property.

Steps 19-24. Create the Resources Data Source.

  1. Click the smart tag of the ASPxScheduler control in Visual Studio designer to invoke a smart tag panel. In the panel, click the Resources Data Source combo box and select the New data source… item.
  2. The Data Source Configuration Wizard window is displayed. Follow the wizard to configure the data source.
  3. First, select the SQL database as a Data Source Type.
  4. Next, choose the data connection.

    ConfigureDataSource.png

  5. Select all columns in the Resources table to include in the data source.

    DataSourceWizard6.png

  6. Click Next so that you can test the data source. Click Finish, and the Mappings Wizard for Resources is invoked. .

Steps 25-26. Specify Resource Mappings.

  1. The window of the Mappings Wizard, entitled Setup Resource Storage, is displayed automatically after you assign an appointment data source for the first time. You can also invoke it any time via the SchedulerControl’s smart tag. To accomplish this, click the smart tag of the ASPxScheduler control in the Visual Studio designer to invoke a smart tag panel. In the panel, click the Mappings Wizard tag under the Resources Data Source caption. The Mappings Wizard is invoked.
  2. Follow the wizard as described in the Mappings Wizards document to specify resource mappings.

    Mappings3.png

Step 28. Result.

  1. Run the project. The ASPxScheduler control is ready to display existing appointments. You can create, modify and delete appointments. All appointment modifications are stored in the MS SQL Server File database located in App_Data.
See Also