Tutorial VB.NET : CRUD (Create, Update, Delete) Vb.Net Database MySQL

Tutorial VB.NET : Cara membuat CRUD (Create, Update, Delete) di Vb.Net 2010 menggunakan Database MySQL PhpMyAdmin dan Connection Odbc

Aplikasi CRUD (Create, Update, Delete) Vb.Net Database MySQL

Tutorial Sector Code kali ini membuat aplikasi CRUD sederhana menggunakan database MySQL di Visual Basic Net 2010, sebelumnya kita harus membuat database di PhpMyadmin terlebih dahulu, baca Tutorial Lengkap Cara Membuat Database MySQL di PhpMyAdmin. dan untuk tutorial ini penulis membuat database seperti gambar berikut :

Tutorial VB.NET : CRUD (Create, Update, Delete) Vb.Net Database MySQL

Buatlah Project baru dengan Nama CRUD, buat Form baru dengan nama FrmUtama.vb, buat design FrmUtama seperti gambar berikut :

Aplikasi Crud Vb Net 2010

Buatlah Module koneksi ke database yang sudah anda buat, baca Tutorial Vb.Net : Koneksi Database MySQL, Buatlah Module baru dengan nama MdlKoneksi, dan pastekan Code berikut :
Imports System.Data
Imports System.Data.Odbc
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Imports System.Data.OleDb
Module MdlKoneksi
    Public konek As OdbcConnection
    Public DA As OdbcDataAdapter
    Public DR As OdbcDataReader
    Public DS As DataSet
    Public CMD As OdbcCommand
    Sub bukaDB()
        Try
            konek = New OdbcConnection("DSN=crud;MultipleActiveResultSets=True")
            If konek.State = ConnectionState.Closed Then
                konek.Open()
            End If
        Catch ex As Exception
            MsgBox("konek Kedatabase Bermasalah, Periksa koneksi Jaringan Anda")
        End Try
    End Sub
End Module
Kode untuk tombol Tambah
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DATABARU = True
        bersih()
    End Sub
Code Untuk Tombol Simpan
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim simpan As String
        Dim vTanggalLahir As String
        Dim vTgl As String
        Dim vBln As String
        Dim vThn As String
        Dim pesan As Integer
        vTgl = DateTimePicker1.Value.Day
        vBln = DateTimePicker1.Value.Month
        vThn = DateTimePicker1.Value.Year
        vTanggalLahir = vThn & "-" & vBln & "-" & vTgl
        If TextBox2.Text = "" Or TextBox3.Text = "" Then Exit Sub
        If DATABARU Then
            pesan = MsgBox("Apakah Anda Yakin Data Akan ditambahkan ke Database ?", vbYesNo + vbInformation, "Perhatian")
            If pesan = vbYesNo Then
                Exit Sub
            End If
            simpan = "INSERT INTO biodata(nama,nis,nisn,jeniskelamin,tempatlahir,tanggallahir,agama,alamat,sekolahasal) VALUES ('" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "'," _
                + " '" & TextBox5.Text & "','" & TextBox6.Text & "','" & vTanggalLahir & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "') "
        Else
            pesan = MsgBox("Anda yakin data ini akan di update ?", vbYesNo + vbInformation, "Perhatian")
            If pesan = vbYesNo Then
                Exit Sub
            End If
            simpan = "UPDATE biodata SET " _
                + "nama = '" & TextBox2.Text & "'," _
                + "nis ='" & TextBox3.Text & "'," _
                + "nisn ='" & TextBox4.Text & "'," _
                + "jeniskelamin ='" & TextBox5.Text & "'," _
                + "tempatlahir ='" & TextBox6.Text & "'," _
                + "tanggallahir ='" & vTanggalLahir & "'," _
                + "agama ='" & TextBox7.Text & "'," _
                + "alamat ='" & TextBox8.Text & "'," _
                + "sekolahasal ='" & TextBox9.Text & "'," _
                + "alamatsekolahasal ='" & TextBox9.Text & "'  WHERE idsiswa = '" & TextBox1.Text & "' "
        End If
        jalankansql(simpan)
        Me.Cursor = Cursors.WaitCursor
        DataGridView1.Refresh()
        isigrid()
        Me.Cursor = Cursors.Default
    End Sub
Code Untuk Tombol Hapus
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim hapussql As String
        Dim pesan As Integer
        pesan = MsgBox("Apakah anda yakin akan menghapus Data pada server .. " + TextBox2.Text, vbExclamation + vbYesNo, "perhatian")
        If pesan = vbNo Then Exit Sub
        hapussql = "DELETE FROM biodata WHERE idsiswa='" & TextBox1.Text & "'"
        jalankansql(hapussql)
        Me.Cursor = Cursors.WaitCursor
        DataGridView1.Refresh()
        isigrid()
        Me.Cursor = Cursors.Default
    End Sub
Code untuk Tombol Keluar
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub
Code Functions Simpan
    Private Sub jalankansql(ByVal sQl As String)
        Dim objcmd As New System.Data.Odbc.OdbcCommand
        Call bukaDB()
        Try
            objcmd.Connection = konek
            objcmd.CommandType = CommandType.Text
            objcmd.CommandText = sQl
            objcmd.ExecuteNonQuery()
            objcmd.Dispose()
            MsgBox("Data Sudah Disimpan", vbInformation)
        Catch ex As Exception
            MsgBox("Tidak Bisa Menyimpan data ke Server" & ex.Message)
        End Try
    End Sub
Code Sub Isidata Ke GridView
    Sub isigrid()
        bukaDB()
        DA = New Odbc.OdbcDataAdapter("SELECT * FROM biodata", konek)
        DS = New DataSet
        DS.Clear()
        DA.Fill(DS, "biodata")
        DataGridView1.DataSource = (DS.Tables("biodata"))
        DataGridView1.Enabled = True
    End Sub
Code Isi Data Dari Gridview Ke TextBox
 Private Sub isiTextBox(ByVal x As Integer)
        Try
            TextBox1.Text = DataGridView1.Rows(x).Cells(0).Value
            TextBox2.Text = DataGridView1.Rows(x).Cells(1).Value
            TextBox3.Text = DataGridView1.Rows(x).Cells(2).Value
            TextBox4.Text = DataGridView1.Rows(x).Cells(3).Value
            TextBox5.Text = DataGridView1.Rows(x).Cells(4).Value
            TextBox6.Text = DataGridView1.Rows(x).Cells(5).Value
            DateTimePicker1.Value = IIf(IsDBNull(DataGridView1.Rows(x).Cells(6).Value), Date.Now,
                                        DataGridView1.Rows(x).Cells(6).Value)
            TextBox7.Text = DataGridView1.Rows(x).Cells(7).Value
            TextBox8.Text = DataGridView1.Rows(x).Cells(8).Value
            TextBox9.Text = DataGridView1.Rows(x).Cells(9).Value
        Catch ex As Exception
        End Try
    End Sub
    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        isiTextBox(e.RowIndex)
        DATABARU = False
    End Sub
Code untuk Frm Load
    Dim DATABARU As Boolean
    Private Sub FrmUtama_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DATABARU = False
        isigrid()
    End Sub
Jika semuanya sudah selesai, silahkan coba aplikasi CRUD anda, gini penampakannya :

Aplikasi Crud Vb Net 2010 baru

Video tutorial CRUD Applikasi Vb.Net bisa anda lihat di sini :



Video Tutorial : CRUD (Create, Update, Delete) Vb.Net
[Video] Tutorial CRUD Vb.NET menggunakan Database SQL Server
atau selengkapnya di halaman video tutorial
[Tutorial Link UPDATED on 21 Mei 2016] How to Create CRUD Operations with MySQL Database and Metro Framework UI Theme Version 2, download full source code English version. Aplikasi CRUD rilis versi 2 bisa kamu temukan pada link diatas, dilengkapi dengan source code yang bisa di download dan video tutorial. semoga bermanfaat.

Video Tutorial CRUD Operations Versi 2



Video Tutorial CRUD dalam DataGridView


Untuk menambah Functions Search Data dan membuat laporannya silahkan baca pada tutorial Sector Code Sebelumnya :
Tutorial Vb.Net : Fungsi Search / Cari Data di DataGridView dan Membuat Laporan Biodata dengan Crystal Report Vb.Net,

[Download Link UPDATED on 21 Mei 2016] Anda juga bisa mendownload aplikasi Crud Sederhana ini, silahkan Download Aplikasi Crud Vb.Net

Jangan lupa di Like dan Share jika bermanfaat, Terima kasih ;)

COMMENTS

Next Recomended


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


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,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,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: Tutorial VB.NET : CRUD (Create, Update, Delete) Vb.Net Database MySQL
Tutorial VB.NET : CRUD (Create, Update, Delete) Vb.Net Database MySQL
Tutorial VB.NET : Cara membuat CRUD (Create, Update, Delete) di Vb.Net 2010 menggunakan Database MySQL PhpMyAdmin dan Connection Odbc
https://3.bp.blogspot.com/-1pdho3i9khQ/VRgn3EtX5eI/AAAAAAAAANo/f52sBADm890/s1600/crud.png
https://3.bp.blogspot.com/-1pdho3i9khQ/VRgn3EtX5eI/AAAAAAAAANo/f52sBADm890/s72-c/crud.png
KODE AJAIB
https://www.kodeajaib.com/2015/03/tutorial-vbnet-crud-create-update-delete.html
https://www.kodeajaib.com/
https://www.kodeajaib.com/
https://www.kodeajaib.com/2015/03/tutorial-vbnet-crud-create-update-delete.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