SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass(); SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass(); srv.Connect(this.cboServers.SelectedItem.ToString(),this.txtUser.Text,this.txtPassword.Text); foreach(SQLDMO.Database db in srv.Databases) { if(db.Name!=null) this.cboDatabase.Items.Add(db.Name); }
http://www.csharphelp.com/archives2/archive342.html
http://zhidao.baidu.com/question/205368661.html?an=0&si=2
SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect(this.cboServers.SelectedItem.ToString(),this.txtUser.Text,this.txtPassword.Text);
foreach(SQLDMO.Database db in srv.Databases)
{
if(db.Name!=null)
this.cboDatabase.Items.Add(db.Name);
}