fakhravari
جمعه 31 مرداد 1393, 09:57 صبح
با سلام
public static bool BackupDatabase(string backUpFile, string DataBaseName, string ServerName = @".\SQLEXPRESS") {
try
{
ServerConnection con = new ServerConnection(ServerName);
Server server = new Server(con);
Backup source = new Backup();
source.Action = BackupActionType.Database;
source.Database = DataBaseName;
BackupDeviceItem destination = new BackupDeviceItem(backUpFile, DeviceType.File);
source.Devices.Add(destination);
source.SqlBackup(server);
con.Disconnect();
return true;
}
catch { return false; }
}
و
protected void Button1_Click(object sender, EventArgs e) {
if (DAL.BackupDatabase(@"~/BakupAndRestor/" + DdlFillDatabaseName.Text + ".bak", DdlFillDatabaseName.Text))
{
Label1.Text = "موفقیت آمیز بود";
}
else
{
Label1.Text = "خطا";
}
}
اما مشکل در اتصال است!!
ServerConnection con = new ServerConnection(ServerName);
public static bool BackupDatabase(string backUpFile, string DataBaseName, string ServerName = @".\SQLEXPRESS") {
try
{
ServerConnection con = new ServerConnection(ServerName);
Server server = new Server(con);
Backup source = new Backup();
source.Action = BackupActionType.Database;
source.Database = DataBaseName;
BackupDeviceItem destination = new BackupDeviceItem(backUpFile, DeviceType.File);
source.Devices.Add(destination);
source.SqlBackup(server);
con.Disconnect();
return true;
}
catch { return false; }
}
و
protected void Button1_Click(object sender, EventArgs e) {
if (DAL.BackupDatabase(@"~/BakupAndRestor/" + DdlFillDatabaseName.Text + ".bak", DdlFillDatabaseName.Text))
{
Label1.Text = "موفقیت آمیز بود";
}
else
{
Label1.Text = "خطا";
}
}
اما مشکل در اتصال است!!
ServerConnection con = new ServerConnection(ServerName);