Export (0) Print
Expand All

Lesson 2: Creating a Connection to the Sample Database

The first step is to create a connection to the AdventureWorks2008R2 sample database in order to generate a list of fields for the report definition.

NoteNote

If you are using SQL Server Express with Advanced Services, the connection data source must include the SQL Server Express named instance. By default, the connection string for the AdventureWorks2008R2 sample database is "Data Source=localhost\SQLExpress; Initial Catalog=AdventureWorks2008R2". For more information, see Reporting Services in SQL Server Express with Advanced Services

To create a connection to AdventureWorks

  • Replace the code for the OpenConnection() method in your project with the following code:

public void OpenConnection()
{
   // Create a connection object
   m_connection = new SqlConnection();
         
   // Create the connection string
   m_connectString = @"data source=localhost;initial catalog=AdventureWorks2008R2;integrated security=SSPI";
   m_connection.ConnectionString = m_connectString; 
         
   // Open the connection
   m_connection.Open();
}
NoteNote

You should replace the connection string used here with a connection string that is valid for your particular configuration. The previous connection string assumes that you have installed the AdventureWorks2008R2 database to a local instance of SQL Server.

Tasks

Tutorial: Generating RDL Using the .NET Framework

Community Additions

ADD
Show:
© 2014 Microsoft