diff --git a/Windows/SQL_BAK.xaml.cs b/Windows/SQL_BAK.xaml.cs index c54506e..905f0d0 100644 --- a/Windows/SQL_BAK.xaml.cs +++ b/Windows/SQL_BAK.xaml.cs @@ -157,49 +157,9 @@ namespace formula_manage.Windows Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASS; } SqlConnection connection = new SqlConnection(Connstr_SC); - // connection.ConnectionString = Connstr_SC; - connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; - command.CommandText = string.Format("select spid from sysprocesses,sysdatabases where sysprocesses.dbid=sysdatabases.dbid and sysdatabases.Name='{0}'", dbName); - // 获取当前所有连接进程 - List list = new List(); - try - { - SqlDataReader reader = command.ExecuteReader(); - while (reader.Read()) - { - list.Add(reader.GetInt16(0)); - } - reader.Close(); - } - catch - { - return false; - } - finally - { - connection.Close(); - } - // 停止当前所有连接进程 - // try - // { - for (int i = 0; i < list.Count; i++) - { - connection.Open(); - command = new SqlCommand(string.Format("use master kill {0}", list[i].ToString()), connection); - command.ExecuteNonQuery(); - connection.Close(); - } - // } - // catch - // { - // return false; - // } - // finally - // { - // connection.Close(); - // } + // 还原数据库 connection.Open(); command.CommandText = string.Format("use master restore database {0} from disk = '{1}' with replace", dbName, filePath);