public void Drop() { try { SmoServer.KillAllProcesses(Name); SmoDatabase.Drop(); } catch (Exception ex) { throw new SqlServerDropException(); } }
private void Delete() { if (!this.VerifyDatabase()) { return; } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Deleting Database: {0}", this.DatabaseItem.ItemSpec)); SMO.Database oldDatabase = new SMO.Database(this.sqlServer, this.DatabaseItem.ItemSpec); oldDatabase.Refresh(); oldDatabase.Drop(); }
public bool DeleteDB(string servername, string username, string password, string DBName) { try { var serverconnection = CreateServerConnection(servername, username, password); var srv = new Microsoft.SqlServer.Management.Smo.Server(serverconnection); //Define a Database object variable by supplying the server and the database name arguments in the constructor. Database db; db = new Microsoft.SqlServer.Management.Smo.Database(srv, DBName); db.Drop(); serverconnection.Disconnect(); return(true); } catch (Exception) { return(false); throw; } }
private void Delete() { if (!this.VerifyDatabase()) { return; } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Deleting Database: {0}", this.DatabaseItem.ItemSpec)); SMO.Database oldDatabase = new SMO.Database(this.sqlServer, this.DatabaseItem.ItemSpec); oldDatabase.Refresh(); oldDatabase.Drop(); }