Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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.
Posted 19-Jun-13 22:16pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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();
}
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 PIEBALDconsult 160
4 CPallini 155
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 2 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100