HomeVb.NetVideo

VB.Net Example : Aplikasi Backup & Restore MySQL Database vb.net

Tutorial belajar vb.net : Membuat aplikasi sederhana untuk membackup dan merestore database mysql menggunakan aplikasi Vb.net, download source code backup & restore database mysql dengan vb.net

CRUD OPERATION REST API using PHP and MYSQLI
#Solved - ERROR Only_full_group_by When Executing a Query in MYSQL
VB.NET AutoComplete TextBox in a DataGridView + MySQL Database
Tutorial Vb.Net Pemula - tutorial .net pada kesempatan kali ini tentang bagaimana cara membuat aplikasi sederhana yang berguna untuk membackup dan restore sebuah database (MySQL) dengan menggunakan pemrogramman vb.net, aplikasi backup dan restore MySQL database ini sangat sederhana, sehingga bagi kamu walaupun masih pemula pasti bisa membuatnya sendiri. Dengan dilengkapi dengan tutorial dan video tutorial serta kamu juga bisa mendownload source code vb.net yang sudah kami siapkan tentunya.

langsung saja buat project baru di Visual studio kamu, saya menggunakan visual studio 2015 pro. buat project baru dengan nama "MySQLTools" dan desain tampilan form1.vb seperti gambar berikut :



Algoritma program :
Ketika user mengisi nama server, user dan password sesuai database server yang dimiliki, maka aplikasi akan mencoba connect dan jika berhasil akan memunculkan daftar list database yang dimiliki ke dalam combobox1, selanjutnya user bisa memilih opsi untuk backup dan restore database yang dipilih sesuai dari combobox text.

langsung saja kita berpusing ria, masuk ke jendela code atau bisa dengan cara klik dua kali pada form1.vb, dan deklarasikan serta import reference yang dibutuhkan. Tambahkan componen OpenFileDialog dan SaveFileDialog ke dalam Project.

Import refernce MySQL.Data


pada menu project > add reference > extensions > MySQL.Data dan OK

Import Namespace kedalam project

Imports MySql.Data.MySqlClient
Imports System.IO

Deklarasikan variable yang dibutuhkan

    Dim SqlConnection As MySqlConnection
    Dim dt As New DataTable
    Dim cmd As String
    Dim dtseCt As Integer
    Dim da As MySqlDataAdapter

Source Code Koneksi Database

    Public Sub koneksi()
        Try
            SqlConnection = New MySqlConnection("Server=" & TextBox1.Text & "; " _
                                                + "user id=" & TextBox2.Text & ";" _
                                                + "password=" & TextBox3.Text & ";")
            If SqlConnection.State = ConnectionState.Closed Then

                SqlConnection.Open() ' open our connections
            End If
        Catch ex As Exception
            MsgBox("Connection Filed !")
        End Try
    End Sub

Source Code Tombol Konek (Button1)

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            koneksi() ' open our connection
            ' create query to show list of our database into combobox
            cmd = "SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES"
            da = New MySqlDataAdapter(cmd, SqlConnection)
            da.Fill(dt)
            dtseCt = 0

            ' enabling the list of database in the combobox
            ComboBox1.Enabled = True
            ComboBox1.Items.Clear()
            ComboBox1.Items.Add("== Select Database ==")

            While dtseCt < dt.Rows.Count

                ' add database list into combobox
                ComboBox1.Items.Add(dt.Rows(dtseCt)(0).ToString())
                dtseCt = dtseCt + 1
                ' lets try
                'sorry for it, just add the code like this

            End While
            ComboBox1.SelectedIndex = 0
            Button1.Enabled = False
            Button2.Enabled = True
            Button3.Enabled = True
            'close our connections
            SqlConnection.Clone()
            dt.Dispose()
            da.Dispose()

        Catch ex As Exception
            MsgBox("Connection Filed!")
        End Try
    End Sub

Source Code Backup Database MySQL

    Private Sub Button2_Click(sender As Object, ByVal e As EventArgs) Handles Button2.Click
        ' we will backup a mysql database and save it into our local server
        Dim DbFile As String
        Try
            ' create svaFileDialog and OpenFileDialog Component to our project
            SaveFileDialog1.Filter = "SQL Dump File (*.sql)|*.sql|All files (*.*)|*.*"
            SaveFileDialog1.FileName = "Database Backup " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".sql"
            If SaveFileDialog1.ShowDialog = DialogResult.OK Then

                koneksi() ' open our connections
                DbFile = SaveFileDialog1.FileName
                Dim BackupProccess As New Process
                BackupProccess.StartInfo.FileName = "cmd.exe"
                BackupProccess.StartInfo.UseShellExecute = False
                BackupProccess.StartInfo.WorkingDirectory = "C:\xampp\mysql\bin\"
                BackupProccess.StartInfo.RedirectStandardInput = True
                BackupProccess.StartInfo.RedirectStandardOutput = True
                BackupProccess.Start()

                Dim BackupStream As StreamWriter = BackupProccess.StandardInput
                Dim myStreamReader As StreamReader = BackupProccess.StandardOutput
                BackupStream.WriteLine("mysqldump --user=" & TextBox2.Text & " _
                + "" --password=" & TextBox3.Text & " -h " & TextBox1.Text & " " _
                + "" & ComboBox1.Text & " > """ + DbFile + """")

                BackupStream.Close()
                BackupProccess.WaitForExit()
                BackupProccess.Close()
                SqlConnection.Close()
                MsgBox("Backup your MySQL database Created Successfully!", MsgBoxStyle.Information, "Backup MySql Database")
            End If

        Catch ex As Exception
            MsgBox("Nothing to do!")
        End Try
    End Sub

Source Code Restore Database MySQL

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ' now we will create for restore our database, just copy the source for backup our database before
        Dim DbFile As String
        Try
            ' create svaFileDialog and OpenFileDialog Component to our project
            OpenFileDialog1.Filter = "SQL Dump File (*.sql)|*.sql|All files (*.*)|*.*"
            If OpenFileDialog1.ShowDialog = DialogResult.OK Then

                koneksi() ' open our connections
                DbFile = OpenFileDialog1.FileName
                Dim BackupProccess As New Process
                BackupProccess.StartInfo.FileName = "cmd.exe"
                BackupProccess.StartInfo.UseShellExecute = False
                BackupProccess.StartInfo.WorkingDirectory = "C:\xampp\mysql\bin\"
                BackupProccess.StartInfo.RedirectStandardInput = True
                BackupProccess.StartInfo.RedirectStandardOutput = True
                BackupProccess.Start()

                Dim BackupStream As StreamWriter = BackupProccess.StandardInput
                Dim myStreamReader As StreamReader = BackupProccess.StandardOutput
                BackupStream.WriteLine("mysql --user=" & TextBox2.Text & " --password=" & TextBox3.Text & " -h " & TextBox1.Text & " " & ComboBox1.Text & " < """ + DbFile + """")

                BackupStream.Close()
                BackupProccess.WaitForExit()
                BackupProccess.Close()
                SqlConnection.Close()
                MsgBox("Restore your MySQL database Successfully!", MsgBoxStyle.Information, "Restore MySql Database")
            End If

        Catch ex As Exception
            MsgBox("Nothing to do!")
        End Try
    End Sub
Setelah semuanya beres, tinggal test aplikasi sederhana yang barusan kamu buat, jika tidak terjadi error maka kamu sudah berhasil membuat aplikasi yang berguna untuk membackup database MySQL, kamu bisa kembangkan sendiri nantinya.

jika masih bingung berikut kami menyertakan video tutorialnya silahkan tonton sendiri.

Download aplikasi backup dan restore database MySQL

jangan lupa share, subscribe jika tutorial ini bermanfaat. terima kasih
Google Plus : https://plus.google.com/u/0/+HarisonMatondang
Youtube : http://www.youtube.com/c/HarisonMatondang
Website : Tutorial Vb.Net Khusus Pemula

Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


COMMENTS

DISQUS
Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,89,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,6,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: VB.Net Example : Aplikasi Backup & Restore MySQL Database vb.net
VB.Net Example : Aplikasi Backup & Restore MySQL Database vb.net
Tutorial belajar vb.net : Membuat aplikasi sederhana untuk membackup dan merestore database mysql menggunakan aplikasi Vb.net, download source code backup & restore database mysql dengan vb.net
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8VoLdelCnncRgoOKVHCxCubE0Bamn4oiuDrV9ukAhZDQogyLFWfsjcFEMWWtP8biGgC4sL5yHmqz0P1q14gQBIB59PupR-aA8Ak8EHK6ba-g_YdUMP3Y08JRFkGDH8CAq4WaDS-PlMtE/s320/membuat-backup-restore-database-mysql.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8VoLdelCnncRgoOKVHCxCubE0Bamn4oiuDrV9ukAhZDQogyLFWfsjcFEMWWtP8biGgC4sL5yHmqz0P1q14gQBIB59PupR-aA8Ak8EHK6ba-g_YdUMP3Y08JRFkGDH8CAq4WaDS-PlMtE/s72-c/membuat-backup-restore-database-mysql.jpg
KODE AJAIB
https://scqq.blogspot.com/2016/05/aplikasi-sederhana-backup-restore-database-mysql.html
https://scqq.blogspot.com/
https://scqq.blogspot.com/
https://scqq.blogspot.com/2016/05/aplikasi-sederhana-backup-restore-database-mysql.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy