Hay!
I need to write a C# based Incremental backup application. From that application only modified database files should be backup from our Database (SQL server Database ) .
Please any one suggest a way to do this. And it is good , if you suggest any tools also.
Thankyou
Basit KhanRank #4,768 · 326 pointsPosted Jan 10, 2016, 1:22 AM EST
using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Data.SqlClient; public class Form1 { SqlConnection con; SqlConnection con1; SqlCommand cmd; SqlDataReader dread; private void Form1_Load(object sender, System.EventArgs e) { connection(); blank("backup"); } public void blank(string str) { string Lsm_Date = null; Lsm_Date = Convert.ToDateTime(Today).ToString("dd-MMM-yyyy"); if (str == "backup") { Timer1.Enabled = true; ProgressBar1.Visible = true; string s = null; s = "D:\DataBackup\" + Lsm_Date + ".bak"; query("backup database <DatabaseName> to disk='" + s + "'"); } } private void Timer1_Tick(System.Object sender, System.EventArgs e) { if (ProgressBar1.Value == 100) { Timer1.Enabled = false; ProgressBar1.Visible = false; System.Environment.Exit(0); } else { ProgressBar1.Value = ProgressBar1.Value + 5; } } public void query(string que) { // ERROR: Not supported in C#: OnErrorStatement cmd = new SqlCommand(que, con); cmd.ExecuteNonQuery(); } public void connection() { con = new SqlConnection("Data Source=.;Database=Master;integrated security=SSPI;"); con.Open(); cmd = new SqlCommand("select * from sysdatabases", con); dread = cmd.ExecuteReader; while (dread.Read) { } dread.Close(); } public Form1() { Load += Form1_Load; } }Kasthu Guna80 pointsPosted Jan 10, 2016, 6:31 PM EST
Basit KhanRank #4,768 · 326 pointsPosted Jan 12, 2016, 8:15 PM EST
Dim sqlConnectionString As String = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBNAME ;Data Source=.\SQLEXPRESS" Dim conn As New SqlConnection(sqlConnectionString) conn.Open() Dim cmd As New SqlCommand cmd.CommandType = CommandType.Text cmd.CommandText = "BACKUP DATABASE DBNAME TO DISK='C:\location.BAK'" cmd.Connection = conn cmd.ExecuteNonQuery()