Are you looking for something like this
string dbName = "Northwind";
SQLDMO.Database db = new SQLDMO.Database();
SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
srv.Name = "(local)";
srv.LoginSecure = true;
srv.Connect(null,null,null);
db = (SQLDMO.Database)srv.Databases.Item(dbName,null);
MessageBox.Show("I have in my hand this database - " + db.Name + " it is
this big " + db.Size.ToString());
srv.DisConnect();
--
--
Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know
"T." <T@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
I dumped VB and adopted C# for this version of Visual Studio. My problem!
I am trying to reference an SQLDMO.Database object in C# like so:
private SQLDMO.Database dbcurrent;
private string dbname;
dbname = "Northwind";
dbcurrent = (SQLDMO.Database)sqlsvr.Databases.Item(dbname);
But I get this error : No overload for method 'Item' takes '1' arguments.
I was hoping to avoid iterating through the SQLDMO.Databases collection to
obtain the ID of the database I want, and reference my target database via
that ID.
e.g. dbcurrent = (SQLDMO.Database)sqlsvr.Databases.ItemByID(i);
Any suggestions? And thanks in advance