2011-05-31 58 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

相关问题