以下为引用的内容: void restoreButton_Click(object sender, System.EventArgs e) { string path = pathTextBox.Text; string dbname = dbDropDownList.SelectedValue; string restoreSql = "use master;"; restoreSql += "restore database @dbname from disk = @path;"; string pai = "use master;ALTER DATABASE Wy SET OFFLINE WITH ROLLBACK IMMEDIATE;ALTER DATABASE Wy SET ONLINE WITH ROLLBACK IMMEDIATE"; SqlConnection conn = new SqlConnection(ConnStr); SqlCommand com1 = new SqlCommand(pai, conn); SqlCommand myCommand = new SqlCommand(restoreSql, new SqlConnection(ConnStr)); myCommand.Parameters.Add("@dbname", SqlDbType.Char); try } } |
时间: 2024-12-21 14:59:20