开发者

Visual Studio 2010 error: "Non-invocable member 'Microsoft.SqlServer.Management.Smo.Server.Databases' cannot be used like a method."

I get the following error when compiling a simple C# console app from MSDN docs, Setting Up a Partition Scheme for a Table in Visual C#:

Non-invocable member 'Microsoft.SqlServer.Managem开发者_如何学Cent.Smo.Server.Databases' 
cannot be used like a method.

The offending line:

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

I'm using Visual Studio 2010.

p.s. To compile this, I created a console app, as described at How to: Create a Visual C# SMO Project in Visual Studio .NET.


I think you want db = srv.Databases["AdventureWorks2008R2"];

Databases is a property that returns a DatabaseCollection, not a method. You then use the default indexer of DatabaseCollection to get your database.

See MSDN.

Your linked page appears to have an mistake.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜