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

How to: Bind a Report to an MS SQL Server Database

  • 2 minutes to read

This tutorial describes how to bind a report to a Microsoft SQL Server.

To bind a report to a Microsoft SQL Server, do the following.

  1. Start Microsoft Visual Studio 2012, 2013, 2015, 2017 or 2019, and create a new Windows Forms Application, or open an existing application.
  2. Drop the SnapControl from the DX19.1: Reporting Toolbox tab onto the application’s main form.
  3. Next, open the PROJECT menu and click the Add New Data Source… command.

    How-to-Bind-Report-to-MS-SQL-Server-01

  4. In the invoked Data Source Configuration Wizard, select Database and click Next.

    How-to-Bind-Report-to-MS-SQL-Server-02

  5. Select Dataset to specify the type of database model, and click Next.

    How-to-Bind-Report-to-MS-SQL-Server-03

  6. On the next page, click New Connection… to specify which data connection should be used.

    How-to-Bind-Report-to-MS-SQL-Server-04

  7. In the invoked Add Connection dialog, set your data source to Microsoft SQL Server, choose the server name from the drop-down menu and specify the database name.

    How-to-Bind-Report-to-MS-SQL-Server-05

    Click OK to apply the changes. In the Data Source Configuration Wizard, click Next.

    How-to-Bind-Report-to-MS-SQL-Server-06

  8. Click Next on the following page to save the newly created connection string to the configuration file.

    How-to-Bind-Report-to-MS-SQL-Server-07

  9. The final wizard page allows you to choose which tables to obtain from the database. After this step, click Finish.

    How-to-Bind-Report-to-MS-SQL-Server-08

  10. Next, connect the application to data by handling the Load event of the application’s main form and adding the following code to the event handler.

    
    using System;
    using System.Windows.Forms;
    using BindToSQL.NorthWindDataSetTableAdapters;
    // ...
    
    private void Form1_Load(object sender, EventArgs e) {
        NorthWindDataSet ds = new NorthWindDataSet();
        var products = new ProductsTableAdapter();
        products.Fill(ds.Products);
    
        snapControl1.Document.DataSource = ds;
    }
    

The Snap application is now ready. Run it to create your report.

To design the report layout, drop fields from the Data Explorer onto the report editing surface.

How-to-Bind-Report-to-MS-SQL-Server-09