Skip to main content
A newer version of this page is available. .
All docs
V21.1

Bind a Report to a MongoDB Instance

  • 3 minutes to read

This topic describes how to bind a report to a MongoDB instance in the Visual Studio Report Designer.

Create a new project and add a blank report to this project. Follow the steps below to bind the report to a MongoDB instance.

Invoke the Data Source Wizard

Click the report’s smart tag, expand the drop-down menu for the Data Source property in the “Report Tasks” list, and click Add Report Data Source.

Invoke the Data Source Wizard

Select the MongoDB Data Source

Select MongoDB in the invoked Data Source Wizard and click Next.

Select the MongoDB Data Source

A reporting application uses the MongoDB.Driver package to supply MongoDB data at runtime. If the driver is not installed in your project, the following wizard page appears:

Install MongoDB driver

Use this page to install the driver.

Specify Connection Properties

Paste the entire string or enter connection fields individually. Refer to the following topic for information on connection string format and options: Connection String URI Format.

Specify connection properties

Save the Connection String

Check the Yes, save a connection as option on the next Data Source Wizard page and specify the name of the connection string to save it. Otherwise, click Next.

Save MongoDB connection

The string is saved to the project’s configuration file and you can use this string when you create a new MongoDB connection.

Reuse MongoDB connection string

Specify Data Queries

On the next page, choose database collections that you want to load from the MongoDB instance. Specify the name of the database and database collection in the Database and Collection columns. You can use the Filter column to specify filter conditions for items of the database collections.

The names of queries to database collections should be unique. A string stored in a query’s Collection column is the default name for this query. To create several queries to the same database collection, use the Alias column to specify different names for these queries.

Configure queries to a MongoDB instance

Use the Created MongoDB Data Source

The created data source appears in the Field List and Report Explorer.

MongoDB data source in the Field List and Report Explorer

You can bind report controls to the fields from this data source. Refer to the following topic for more information: Bind Report Controls to Data.

Modify the Created MongoDB Data Source

You can change connection parameters and modify queries for the created data source. Right-click the data source node in the Field List or Report Explorer and select Configure Connections or Manage Queries.

Modify MongoDB Data Source

Reconfigure the connection parameters or queries in the invoked Connection Editor and click Finish.

Reconfigure MongoDB Data Source

Right-click the data source node and select Rebuild Result Schema to apply the changes.

Rebuild Result Schema