急求:大家帮忙给我注释一段代码,有关数据库恢复的
string sql="Persist Security Info=False;Data Source=Localhost;Integrated security=SSPI;Initial catalog=paike; ";sql+="server=(local);Database=paike;Uid=sa;Pwd='123456'";
SqlConnection con=new SqlConnection(sql);
con.open();
SqlCommand cmd = new SqlCommand("SELECT spid FROM sysprocesses ,sysdatabases WHERE sysprocesses.dbid=sysdatabases.dbid AND sysdatabases.Name='paike'", con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
ArrayList list = new ArrayList();
while(dr.Read())
{
list.Add(dr.GetInt16(0));
}
dr.Close();
for(int i = 0; i < list.Count; i++)
{
cmd = new SqlCommand(string.Format("KILL {0}", list[i]), con);
cmd.ExecuteNonQuery();
}
SqlCommand cmdRT = new SqlCommand();
cmdRT.CommandType = CommandType.Text;
cmdRT.Connection = con;
cmdRT.CommandText = @"restore database paike from disk='d:\paike'";
try
{
cmdRT.ExecuteNonQuery();
MessageBox.Show("恢复成功.");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
在执行过程中提示"系统错误"那里有错啊
请大家也帮忙改一下
补充:.NET技术 , C#