ghrezahaj
یک شنبه 23 اسفند 1388, 11:41 صبح
SqlConnection mysqlConnection;
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
mysqlConnection = new SqlConnection("Data Source=localhost;database=test;Integrated Security=true");
mysqlConnection.Open();
SqlCommand mySqlCommand= new SqlCommand();
mySqlCommand = mysqlConnection.CreateCommand();
mySqlCommand.CommandText = "select * from users ";
mySqlDataAdapter.SelectCommand = mySqlCommand;
DataTable dt = new DataTable();
mySqlDataAdapter.Fill(dt);
mysqlConnection.Close();
bindingSource1.DataSource = dt;
userId.DataSource = bindingSource1;
userId.DisplayMember = "userId";
mysqlConnection.ConnectionString= "Data Source=localhost;database=master;Integrated Security=true";
try
{
this.Cursor = Cursors.WaitCursor;
mysqlConnection.Open();
mySqlCommand.CommandText = @"restore database tets from disk='C:test.bak' with replace ";
int success = (int)mySqlCommand.ExecuteNonQuery();
mysqlConnection.Close();
this.Cursor = Cursors.Default;
MessageBox.Show("عملیات یازیابی با موفقیت انجام شد");
}
catch
{
this.Cursor = Cursors.Default;
mysqlConnection.Close();
MessageBox.Show("اخطار : عملیات یازیابی با موفقیت انجام نشد");
}
این پیغام خطا تو قسمت catch ظاهر می شه
Exclusive access could not be obtained because the database is in use.
RESTORE DATABASE is terminating abnormally.
داخل sql studio manager هم نیستم
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
mysqlConnection = new SqlConnection("Data Source=localhost;database=test;Integrated Security=true");
mysqlConnection.Open();
SqlCommand mySqlCommand= new SqlCommand();
mySqlCommand = mysqlConnection.CreateCommand();
mySqlCommand.CommandText = "select * from users ";
mySqlDataAdapter.SelectCommand = mySqlCommand;
DataTable dt = new DataTable();
mySqlDataAdapter.Fill(dt);
mysqlConnection.Close();
bindingSource1.DataSource = dt;
userId.DataSource = bindingSource1;
userId.DisplayMember = "userId";
mysqlConnection.ConnectionString= "Data Source=localhost;database=master;Integrated Security=true";
try
{
this.Cursor = Cursors.WaitCursor;
mysqlConnection.Open();
mySqlCommand.CommandText = @"restore database tets from disk='C:test.bak' with replace ";
int success = (int)mySqlCommand.ExecuteNonQuery();
mysqlConnection.Close();
this.Cursor = Cursors.Default;
MessageBox.Show("عملیات یازیابی با موفقیت انجام شد");
}
catch
{
this.Cursor = Cursors.Default;
mysqlConnection.Close();
MessageBox.Show("اخطار : عملیات یازیابی با موفقیت انجام نشد");
}
این پیغام خطا تو قسمت catch ظاهر می شه
Exclusive access could not be obtained because the database is in use.
RESTORE DATABASE is terminating abnormally.
داخل sql studio manager هم نیستم