PDA

View Full Version : بازیابی فایل پشتیبان شده



navid1n2000
سه شنبه 26 خرداد 1388, 17:57 عصر
من یک دیتابیس دارم که توی یک قسمت ازبرنامه ازش پشتیبان می گیرم :


SqlConnection objConnection = new SqlConnection("Server=PC;Database=VamDB;Integrated Security = True");
SqlDataAdapter objDataAdapter = new SqlDataAdapter();
objDataAdapter.SelectCommand = new SqlCommand();
objDataAdapter.SelectCommand.Connection = objConnection;
objDataAdapter.SelectCommand.CommandText = "Backup DataBase VamDB To Disk = '"+Masir+"' With INIT ";
objDataAdapter.SelectCommand.CommandType = CommandType.Text;
objConnection.Open();
objDataAdapter.SelectCommand.ExecuteNonQuery();
objConnection.Close();
MessageBox.Show("¢ىیى پ¬¢ی ںë ںêيهçی¢ ںë¤ںê ¬§", "êيهçی¢ مêéیں¢", MessageBoxButtons.OK, MessageBoxIcon.Information);

---------------------------------
بعد در کدزیر ازش بازیابی میکنم :


SqlConnection objConnection = new SqlConnection("Server=PC;Database=VamDB;Integrated Security = True");
SqlDataAdapter objDataAdapter = new SqlDataAdapter();
objDataAdapter.SelectCommand = new SqlCommand();
objDataAdapter.SelectCommand.Connection = objConnection;
objDataAdapter.SelectCommand.CommandText = "Restore DataBase VamDB From Disk= '" + Masir + "' ";
objDataAdapter.SelectCommand.CommandType = CommandType.Text;
objConnection.Open();
objDataAdapter.SelectCommand.ExecuteNonQuery();
objConnection.Close();

اما این اررور رو میده؟
http://upload.iranblog.com/6/1245198633.jpg

NewFoxStudent
سه شنبه 26 خرداد 1388, 20:01 عصر
SqlConnection objConnection = newSqlConnection("Server=PC;Database=VamDB;Integrated Security = True");

این خط رو به این صورت تغییر بده


SqlConnection objConnection = newSqlConnection("Server=PC;Database=master;Integrated Security = True");