Hi all does anyone have a working example of this progress class as I cant seem to figure out from the help manual how to get it to work and there are no examples there either.
Any help would be most appreciated.
MySqlDumpProgressEventArgs getting the progess example
-
Serious
MySqlDump.Progress event behaves like common .NET event. Here is a simple example on how to use it:
Code: Select all
public static void WriteProgress(object sender, MySqlDumpProgressEventArgs args) {
Console.WriteLine("ObjectType:\""+ args.ObjectType + "\" Name:\"" + args.ObjectName + "\" Object #" + args.ObjectNumber + "/" + args.ObjectCount + " Progress:" + args.Progress.ToString() + "/" + args.MaxProgress.ToString());
}
[STAThread]
static void Main(string[] args) {
MySqlConnection connection = new MySqlConnection("host=localhost;database=test;user id=root;password=root;");
MySqlDump dump = new MySqlDump();
dump.Connection = connection;
dump.Tables = "dept";
dump.IncludeDrop = true;
connection.Open();
try {
dump.Progress += new MySqlDumpProgressEventHandler(WriteProgress);
dump.Backup();
dump.Restore();
}
finally {
connection.Close();
}
}Not Familiar with C
Hi Serious,,
Thanks for the reply, I should have mentioned that I am using vb and I dont know C very well at all (if at all). I tried to convert what you gave me with no luck. Do you have an example in vb at all.
Thanks for your help
Nick
Thanks for the reply, I should have mentioned that I am using vb and I dont know C very well at all (if at all). I tried to convert what you gave me with no luck. Do you have an example in vb at all.
Thanks for your help
Nick
-
Serious
Actually that was a C#. Anyway, here is my quick translation to VB.NET:
Code: Select all
Imports CoreLab.MySql
Module Module1
Sub WriteProgress(ByVal sender As Object, ByVal args As MySqlDumpProgressEventArgs)
Console.WriteLine("ObjectType:" + args.ObjectType + " Name:" + args.ObjectName + " Object #" + args.ObjectNumber.ToString() + "/" + args.ObjectCount.ToString() + " Progress:" + args.Progress.ToString() + "/" + args.MaxProgress.ToString())
End Sub
Sub Main()
Dim connection As MySqlConnection = New MySqlConnection("host=server;port=3307;database=test;user id=root;password=root;")
Dim dump As MySqlDump = New MySqlDump
dump.Connection = connection
dump.Tables = "dept"
dump.IncludeDrop = True
connection.Open()
Try
AddHandler dump.Progress, New MySqlDumpProgressEventHandler(AddressOf WriteProgress)
dump.Backup()
dump.Restore()
Finally
connection.Close()
End Try
End Sub