Backup My SQL from Asp.net
Example code for how to take my sql backup from asp.net c#
Posted on 03 Apr 2017 Category: Asp.net
Edited on 10 Aug 2017
Here I am going to show how to take My SQL backup from Asp.net.
For that you need to install MySqlBackup.NET from Package manager Console. To Install through package manager console , Open Package manager console and type the following command.
PM> Install-Package MySqlBackup.NET
Or download dll file from https://mysqlbackupnet.codeplex.com
To backup SQL file write the following code, and before running make sure that the host name in the connection string have the full permission on database.
protected void btnBakup_Click(object sender, EventArgs e)
MemoryStream ms = new MemoryStream();
using (MySqlConnection conn = new MySqlConnection(BusinessService.ConnectionString))
MySqlCommand cmd = new MySqlCommand();
MySqlBackup mb = new MySqlBackup(cmd);
cmd.Connection = conn;
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=BackupMyPrj"+DateTime.Now+".sql");