2011-05-31 34 views
2

我編譯從MSDN文檔一個簡單的C#控制檯應用程序,Setting Up a Partition Scheme for a Table in Visual C#當出現以下錯誤:Visual Studio 2010錯誤:「非可調用成員'Microsoft.SqlServer.Management.Smo.Server.Databases'不能像方法一樣使用。」

Non-invocable member 'Microsoft.SqlServer.Management.Smo.Server.Databases' 
cannot be used like a method. 

出錯行:

//Reference the AdventureWorks2008R2 database. 
db = srv.Databases("AdventureWorks2008R2"); 

我使用Visual Studio 2010中

PS爲了編譯這個,我創建了一個控制檯應用程序,如How to: Create a Visual C# SMO Project in Visual Studio .NET所述。

回答

5

我想你想db = srv.Databases["AdventureWorks2008R2"];

數據庫是一個返回DatabaseCollection,不是方法的屬性。然後使用DatabaseCollection的默認索引器來獲取數據庫。

請參閱MSDN

您的鏈接頁面似乎有錯誤。

+0

這工作*出色*!謝謝! – Contango 2011-05-31 12:09:28

相關問題