text

jasa pembuatan software

Sunday, September 13, 2015

Membuat Fungsi Refresh Data Otomatis pada VB.Net dan Database MySQL

Saat membuat program dengan VB.Net dan database MySQL dan kita membuat 2 form berbeda untuk input data dan menampilkan data. seperti berikut:


1. Form untuk menampilkan data:

2. Form untuk input data:

Pada saat kita selesai input data pada form ke 2, di form pertama yang berisi keseluruhan data maka data yang baru saja diinputkan belum ada, dan form harus ditutup dahulu dan dibuka kembali, untuk memperbarui seluruh data, karena cara kerja aplikasi desktop memang tidak dapat me-refresh data secara otomatis. Namun kita dapat membuat sebuah fungsi untuk melakukan refresh otomatis tanpa harus menutup dan membuka form berkali-kali. Berikut codingnya:

 Private Sub refreshDatagrid()
        Try
            Call koneksiku()

            ds = New DataSet

            Tabel = "SELECT * FROM anggota"
            Grid = New Odbc.OdbcDataAdapter(Tabel, Database)
            Grid.Fill(ds, "anggota")

            Anggota.DgAnggota.Columns(0).HeaderText = "NO ANGGOTA"
            Anggota.DgAnggota.Columns(1).HeaderText = "NAMA"
            Anggota.DgAnggota.Columns(2).HeaderText = "ALAMAT"
            Anggota.DgAnggota.Columns(3).HeaderText = "NO TELEPON"
            Anggota.DgAnggota.Columns(4).HeaderText = "TANGGAL BERGABUNG"
            Anggota.DgAnggota.Columns(5).HeaderText = "SIMPANAN POKOK"
            Anggota.DgAnggota.Columns(6).HeaderText = "TANGGAL WAJIB"
            Anggota.DgAnggota.Columns(7).HeaderText = "TANGGAL SUKARELA"
            Anggota.DgAnggota.Columns(8).HeaderText = "PINJAMAN"

            Dim GridView As New DataView(ds.Tables("anggota"))
            Anggota.DgAnggota.DataSource = GridView

        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try
    End Sub

Taruh coding diatas pada form ke 2, dan panggil fungsi diatas setelah button simpan ditekan, sehingga saat selesai input data, secara otomatis data baru akan langsung masuk di form 1.

4 comments:

  1. ada gak coding refresh vb6 untuk adodc?

    ReplyDelete
  2. kalo menggunakan Mysql apa hanya di ganti koneksi db saja ?

    ReplyDelete
  3. Do you understand there is a 12 word phrase you can speak to your crush... that will induce intense emotions of love and impulsive attractiveness for you buried within his heart?

    Because hidden in these 12 words is a "secret signal" that fuels a man's impulse to love, cherish and protect you with all his heart...

    ===> 12 Words Who Fuel A Man's Love Instinct

    This impulse is so hardwired into a man's mind that it will drive him to work harder than ever before to take care of you.

    In fact, triggering this all-powerful impulse is so important to getting the best ever relationship with your man that the second you send your man one of these "Secret Signals"...

    ...You will immediately find him open his mind and soul to you in a way he never experienced before and he will perceive you as the only woman in the world who has ever truly tempted him.

    ReplyDelete