public static DataTable GetAllBackupHistory() { try { TopFashion.SQLDBHelper SqlHelper = new TopFashion.SQLDBHelper(); string sql = "select * from Record order by ID desc"; DataTable dt = SqlHelper.Query(sql, true); return(dt); } catch (Exception e) { TopFashion.WriteLog.CreateLog("数据库操作", "GetAllBackupHistory", "error", "获取备份的历史记录失败:" + e.Message); return(null); } }
private static void KillProcess(string DbName) { string sql = "select spid from sys.sysprocesses where dbid in (select dbid from master..sysdatabases where name = '" + DbName + "')"; TopFashion.SQLDBHelper SqlHelper = new TopFashion.SQLDBHelper(); DataTable dt = SqlHelper.Query(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { try { SqlHelper.ExecuteSql("kill " + dt.Rows[i][0].ToString()); } catch { }//避免KILL自身进程造成错误! } } }