首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

各位大仙看看小弟我这出什么错了.

2012-05-01 
各位大仙看看我这出什么错了....各位大仙看看我这程序出什么错了,恢复数据库这块好像有问题。。执行到红色的

各位大仙看看我这出什么错了....
 
  各位大仙看看我这程序出什么错了,恢复数据库这块好像有问题。。执行到红色的函数那里运行出问题,还原不成功。。。


 

C# code
else//恢复数据库        {            try            {                if (fulFile.HasFile)                {                    SqlCommand command = new SqlCommand("use master;restore database @name from disk=@path;", connection);                    connection.Open();                    string path = fulFile.PostedFile.FileName;  //获取备份文件                    command.Parameters.AddWithValue("@name", dbName);                    command.Parameters.AddWithValue("@path", path);                   [color=#FF0000] command.ExecuteNonQuery();[/color]                    ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('还原成功!');</script>");                    connection.Close();                }                else                {                    ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('请先选择备份的文件位置!');</script>");                }            }            catch (Exception ex)            {                 ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('还原数据库失败!原因是:"+ex.Message+"');</script>");                    }        }


[解决办法]
是master这个数据库吗
[解决办法]
SqlCommand command = new SqlCommand("use master restore database @name from disk='@path' ", connection);

热点排行