خرید بک لینک

با تشکر از مدیران و درخواست دارم این تاپیک رو حذف نکنن من تمام تاپیک های مشابه رو برسی کردم و به نتیجه نرسیدم

سلام دوستان من میخام از دیتابیس express با روش SMO بک اپ بگیرم ولی با این خطا رو به رو میشم

اینم کل کد های کلاس بک اپ و ریستور

namespace Farmer //bayad ba tavajoh be "namespace" baame, tanzim shavad
{
class Backup_Restore : IDisposable
{
private string BackUpConString = @"data source=.\SQLEXPRESS;initial catalog=Database1;integrated security=True";//Coection String baraye Dastyabi be Data base Asli
private string ReStoreConString = @"Data Source=.SQLEXPRESS;Initial Catalog=master;Integrated Security=True";//Coection String baraye dastresi be data base Master

//------------------------------------------------------------

public void Dispose()
{
GC.SuppressFinalize(this);
}

//-------------------------------------------------------------
public void ReStorMyDB()
{
if (MessageBox.Show("All Data Stored in the Database may change!!! n If you agree, select "Yes".", "DataBase ReStore", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{

SqlCoection.ClearAllPools();
using (SqlCoection con = new SqlCoection(ReStoreConString))
{
ServerCoection srvCo = new ServerCoection(con);
Server srvr = new Server(srvCo);

if (srvr != null)
{
try
{

Restore rstDatabase = new Restore();
rstDatabase.Action = RestoreActionType.Database;
rstDatabase.Database = "Database1";//Bayad ham nam ba Data base baame tanzim shavad
OpenFileDialog opfd = new OpenFileDialog();
opfd.Filter = "BackUp File|*.araDB";
if (opfd.ShowDialog() == DialogResult.OK)
{

BackupDeviceItem bkpDevice = new BackupDeviceItem(opfd.FileName, DeviceType.File);

rstDatabase.Devices.Add(bkpDevice);
rstDatabase.ReplaceDatabase = true;
rstDatabase.SqlRestore(srvr);
MessageBox.Show("Database succefully restored", "Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception e)
{
MessageBox.Show("ERROR: An error ocurred while restoring the database", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

}
}

public void BackUpMyDB()
{
using (SqlCoection con = new SqlCoection(BackUpConString))
{
ServerCoection srvCo = new ServerCoection(con);
Server srvr = new Server(srvCo);

if (srvr != null)
{
try
{

Backup bkpDatabase = new Backup();
bkpDatabase.Action = BackupActionType.Database;
bkpDatabase.Database = "Database1";//Bayad ham nam ba Data base baame tanzim shavad
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "BackUp File|*.araDB";
sfd.FileName = "BackUp_" + (DateTime.Now.ToShortDateString().Replace('/', '.'));
if (sfd.ShowDialog() == DialogResult.OK)
{
BackupDeviceItem bkpDevice = new BackupDeviceItem(sfd.FileName, DeviceType.File);
bkpDatabase.Devices.Add(bkpDevice);
bkpDatabase.SqlBackup(srvr);
MessageBox.Show("Bakup of Database successfully created", "Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception e) { MessageBox.Show(e.ToString()); }
}
}
}

}
}

و اینم کانکشن من در فایل app.config

  coectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirector  y|Database1.mdf;Integrated Security=True;User Instance=True"

ممنون میشم راهنمایی کنید

- - , .

برچسب: نویسنده: محمد رضا جوادیان تاريخ: جمعه 14 اسفند 1394 ساعت: 23:20

صفحه بندی