Quantcast
Channel: WinDev Forum
Viewing all articles
Browse latest Browse all 1914

[WD] How to (easily) backup/restore a MySql Database using a .Net assembly (no replies)

$
0
0
Hello to All

After few attempts to find how to use the .net assembly with Windev, i have been able to find the solution and i would like to show you this simple code:

First you need to download the .dll (MySql.Data.dll and MySqlBackup.dll) from this site: [mysqlbackupnet.codeplex.com]

Then create two buttons on your form (Backup and Restore) with this code:
conString   	is string="server=localhost;user=root;pwd=querty;database=test;"
conString+=	"charset=utf8;convertzerodatetime=true;"
conn		is  object	MySql.Data.MySqlClient.MySqlConnection (conString)
filename          is  string="Backup.Sql"

cmd      		is  object	MySql.Data.MySqlClient.MySqlCommand(conString,conn)
mb			is  object 	MySqlBackup (cmd)


conn.Open()
mb.ExportToFile(filename)   // to backup the database
//mb.ImportFromFile(filename) //to restore from dump file
conn.Close()

Hope in this help

Thanks for your attention
Gianni

Viewing all articles
Browse latest Browse all 1914

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>