التنبيهات التالية ظهرت :
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 864 - File: showthread.php PHP 7.4.33 (Linux)
File Line Function
/showthread.php 864 errorHandler->error



تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[مشروع] تصدير واسترجاع mysql db
#1
السلام عليكم ورحمة الله وبركاته
مثال سريع يحتوي كافة الملفات اللازمة 
تذكر انك تحتاج للتعديل على خيارات mysql وبعض مافي جملة الاتصال
والتالي كلاس الفورم 
PHP كود :
Imports MySql.Data.MySqlClient

Public Class Form1

    Private 
Function gname() As String
        Dim t 
As String Now.Year Now.Month Now.Day Now.Hour Now.Minute Now.Second Now.Millisecond
        Return t
    End 
Function

 
   Dim constr As String ""
 
   Dim dbpath As String ""
 
   Dim sconstr As String ""
 
   Private Sub pic1(ByVal l As Boolean)
 
       If pic.InvokeRequired Then
            pic
.Invoke(New Action(Of Boolean)(AddressOf pic1), l)
 
       Else
            pic
.Visible l
        End 
If
 
   End Sub
    Private Sub lbl1
(ByVal l As String)
 
       If lbl.InvokeRequired Then
            lbl
.Invoke(New Action(Of String)(AddressOf lbl1), l)
 
       Else
            lbl
.Text l
        End 
If
 
   End Sub

    Private Sub lblc
(ByVal l As Color)
 
       If lbl.InvokeRequired Then
            lbl
.Invoke(New Action(Of Color)(AddressOf lblc), l)
 
       Else
            lbl
.ForeColor l
        End 
If
 
   End Sub


    Private Sub Button1_Click
(sender As System.ObjectAs System.EventArgsHandles Button1.Click
        Dim fbd 
As New FolderBrowserDialog
        If fbd
.ShowDialog Windows.Forms.DialogResult.OK Then
            txtdbpath
.Text fbd.SelectedPath "\"
        End If
        My.Settings.Apath = txtdbpath.Text
        My.Settings.Save()
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        If MsgBox("
متاكد من بدء النسخ؟", MsgBoxStyle.Critical + MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub
        If b1.IsBusy = False Then
            For Each h As Control In Me.Controls
                If TypeOf h Is Button Then
                    h.Enabled = False
                End If
            Next
            constr = txtconstr.Text
            dbpath = txtdbpath.Text
            b1.RunWorkerAsync()
        End If
    End Sub

    Private Sub b1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles b1.DoWork
        pic1(True)
        lbl1("
النسخ يعمل")
        lblc(Color.Red)
        Using con As New MySqlConnection(constr)
            Using cmd As New MySqlCommand()
                Using mb As New MySqlBackup(cmd)
                    cmd.Connection = con
                    If con.State = ConnectionState.Closed Then con.Open()
                    mb.ExportToFile(dbpath & gname() & "
_vb4arb.sql")
                    If con.State = ConnectionState.Open Then con.Close()

                End Using
            End Using
        End Using
    End Sub

    Private Sub b1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles b1.RunWorkerCompleted
        pic1(False)
        lbl1("
إنتهى النسخ او التصدير او سحب القاعدة")
        lblc(Color.Green)
        Me.Invoke(New MethodInvoker(Sub()
                                        For Each h As Control In Me.Controls
                                            If TypeOf h Is Button Then
                                                h.Enabled = True
                                            End If
                                        Next
                                    End Sub))

    End Sub

    Dim fname As String = ""
    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        If MsgBox("
متاكد من بدء الاسترجاع؟", MsgBoxStyle.Critical + MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub


       

        Dim f As New OpenFileDialog
        If f.ShowDialog = Windows.Forms.DialogResult.OK Then
            fname = f.FileName
        End If
        If b2.IsBusy = False Then
            For Each h As Control In Me.Controls
                If TypeOf h Is Button Then
                    h.Enabled = False
                End If
            Next
            sconstr = txtsconstr.Text
            b2.RunWorkerAsync()
        End If
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtdbpath.Text = My.Settings.Apath
    End Sub

    Private Sub b2_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles b2.DoWork
        pic1(True)
        lbl1("
الاسترجاع يعمل")
        lblc(Color.Red)
        Using con As New MySqlConnection(sconstr)
            Using cmd As New MySqlCommand()
                Using mb As New MySqlBackup(cmd)
                    cmd.Connection = con
                    If con.State = ConnectionState.Closed Then con.Open()
                    ' mb.ExportToFile(dbpath & gname() & "
.sql")
                    mb.ImportFromFile(fname)
                    If con.State = ConnectionState.Open Then con.Close()
                End Using
            End Using
        End Using
    End Sub

    Private Sub b2_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles b2.RunWorkerCompleted
        pic1(False)
        lbl1("
إنتهى الاسترجاع")
        lblc(Color.Green)
        Me.Invoke(New MethodInvoker(Sub()
                                        For Each h As Control In Me.Controls
                                            If TypeOf h Is Button Then
                                                h.Enabled = True
                                            End If
                                        Next
                                    End Sub))
    End Sub
End Class 


الملفات المرفقة
.zip   MysqlBackup_forAll.zip (الحجم : 346.45 ك ب / التحميلات : 182)
الرد }}}


الردود في هذا الموضوع
تصدير واسترجاع mysql db - بواسطة سعود - 17-07-18, 09:33 PM
RE: تصدير واسترجاع mysql db - بواسطة Done - 17-07-18, 10:38 PM
RE: تصدير واسترجاع mysql db - بواسطة Amir_Alzubidy - 17-07-18, 11:26 PM
RE: تصدير واسترجاع mysql db - بواسطة dametucorazon - 21-07-18, 01:43 AM
RE: تصدير واسترجاع mysql db - بواسطة YousefOkasha - 21-07-18, 01:53 AM
RE: تصدير واسترجاع mysql db - بواسطة سعود - 21-07-18, 02:32 AM
RE: تصدير واسترجاع mysql db - بواسطة YousefOkasha - 21-07-18, 10:03 AM
RE: تصدير واسترجاع mysql db - بواسطة سعود - 21-07-18, 02:01 PM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم