第一步是建立通往 AdventureWorks 範例資料庫的連接,以產生報表定義的欄位清單。
附註: |
|---|
| 如果您使用 SQL Server 2005 Express Edition with Advanced Services,連接資料來源中必須包含 SQL Server Express 具名執行個體。依預設,AdventureWorks 範例資料庫的連接字串為 "Data Source=localhost\SQLExpress; Initial Catalog=AdventureWorks"。如需詳細資訊,請參閱<SQL Server 2005 Express Edition with Advanced Services 中的 Reporting Services> |
若要建立通往 AdventureWorks 的連接
- 以下列程式碼取代成專案中 OpenConnection() 方法的程式碼:
Public Sub OpenConnection()
' Create a connection object
m_connection = New SqlConnection()
' Create the connection string
m_connectString = "data source=localhost;initial catalog=AdventureWorks;integrated security=SSPI"
m_connection.ConnectionString = m_connectString
' Open the connection
m_connection.Open()
End Sub 'OpenConnection
public void OpenConnection()
{
// Create a connection object
m_connection = new SqlConnection();
// Create the connection string
m_connectString = @"data source=localhost;initial catalog=AdventureWorks;integrated security=SSPI";
m_connection.ConnectionString = m_connectString;
// Open the connection
m_connection.Open();
}
附註: |
|---|
| 您應該以對您特定組態有效的連接字串來取代這裡使用的連接字串。先前的連接字串假設您已將 AdventureWorks 資料庫安裝到 SQL Server 的本機執行個體。 |
請參閱
工作
第 3 課:擷取報表定義的欄位清單
教學課程:利用 .NET Framework 來產生 RDL
附註: