SQLserver C# Database Backup
In this post I will be showing a simple ways to backup your database from C# application
- Microsoft SQL Server is a relational database management system developed by Microsoft. As a database, it is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network (including the Internet). There are at least a dozen different editions of Microsoft SQL Server aimed at different audiences and for workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users. Its primary query languages are T-SQL and ANSI SQL. (From Wikipedia)
- To use SQL Server connection in your application you should include the <System.Data.SqlClient> Namespace using the code above
using System.Data.SqlClient;
The following code block demonstrates how to create a full database backup
string SQL = string.Format(@"BACKUP database {0} to disk ='D:\backup\{0}.bak'",ListeDB.SelectedItem.ToString());
SqlCommand cmd = new SqlCommand(SQL, cnnx);
cnnx.Open();
cmd.ExecuteNonQuery();
cnnx.Close();
Download
For more information on SHA1 : http://msdn.microsoft.com/