什么是在本地destop上备份s​​ql并将其上传到在线服务器上的更好方法。 [英] What is a better way to take a sql back up at local destop and upload it on online server.

查看:42
本文介绍了什么是在本地destop上备份s​​ql并将其上传到在线服务器上的更好方法。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i想知道在我的应用程序中本地保存sql数据库的最佳方法,这个备份文件将上传到在线服务器。

Hello

i want to know the best way to save a sql database in locally throught my application and this back up file will be upload to online server.

推荐答案

只需通过SQL Management Studio备份,然后在在线服务器上恢复该备份。请记住重新分配所需的任何用户权限。
Just back it up via SQL Management Studio and then restore that backup on the online server. Remember to re-assign any user permissions required.


在BCP(批量复制程序)的帮助下.i将表格备份到文本文件中,然后将文本文件上传到服务器。







拳头我在当地开车回来

拳头拿一个windows form.in里面加两个按钮

1)备份

2)上传



点击备份按钮



private void btnBackup_Click(object sender,EventArgs e)

{

string path =D:\\ \\\Backup \\;

string newpath = path.Replace(\\,//);

filename = filename + .txt;

dBTablename =allot_table_copy; //这是一个表名

System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(cmd ,/ c+bcp DATABASENAEM.dbo。+ dBTablename +out+ path + filename + -U sa -P lock123 -S RUMTEK7-PC\\BREEDSQLEXPRESS -c -E);

procStartInfo.RedirectStandardOutput = true;

procStartInfo.UseShellExecute = false ;

procStartInfo.CreateNoWindow = true;

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.StartInfo = procStartInfo;

proc.Start();

string result = proc.StandardOutput.ReadToEnd();



}



现在点击上传按钮



要在线sqlserver上传此备份



private void upload_Click(object sender,EventArgs e)

{

FolderBrowserDialog fbd = new FolderBrowserDialog();

fbd.ShowDialog();

DestinationPath = fbd.SelectedPath +\\;

if(DestinationPath!=)

{

string newpath = DestinationPath.Replace(\\,//);

filename = filename +。txt;

dBTableName =allot_table_copy; //表名

System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo(cmd,/ c+bcp DATABASE NAME。 dbo。+ dBTableName +out+ DestinationPath + filename + - U username-P password-S Hear is your ip -c -E);

procStartInfo.RedirectStandardOutput = true;

procStartInfo.UseShellExecute = false;

procStartInfo.CreateNoWindow = true;

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.StartInfo = procStartInfo;

proc.Start();

string result = proc.StandardOutput.ReadToEnd();

}

}
With the help of BCP (Bulk Copy Program).i take a table back up in text file and then upload text file into sever.



Fist i take a back in local drive
fist take a windows form.in which add two button
1) backup
2) upload

click on backup button

private void btnBackup_Click(object sender, EventArgs e)
{
string path = "D:\\Backup\\";
string newpath = path.Replace("\\", "//");
filename = filename + ".txt";
dBTablename = "allot_table_copy";//This is a table name
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "bcp DATABASENAEM.dbo." + dBTablename + " out " + path + filename + " -U sa -P lock123 -S RUMTEK7-PC\\BREEDSQLEXPRESS -c -E ");
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();

}

Now click on Upload button

To uploading this backup on online sqlserver

private void upload_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowDialog();
DestinationPath = fbd.SelectedPath +"\\";
if (DestinationPath != "")
{
string newpath = DestinationPath.Replace("\\", "//");
filename = filename + ".txt";
dBTableName = "allot_table_copy";//Table name
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "bcp DATABASE NAME.dbo." + dBTableName + " out " + DestinationPath + filename + " -U username-P password-S Hear is your ip -c -E ");
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
}
}


这篇关于什么是在本地destop上备份s​​ql并将其上传到在线服务器上的更好方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆