Koneksi modul database MYSQL using code vb.net

Free Tutorial by hunianrakyat.com
KONEKSI  MODUL
+++++++++++++++++++++++++++++

Imports System.Data.Odbc
Imports System.Data
Module Module1
    Public conn As OdbcConnection
    Public da As OdbcDataAdapter
    Public ds As DataSet
    Public strcon As String

    Public Sub SAMBUNG()
        strcon = "Driver={MySQL ODBC 3.51 Driver};database=bbm;server=localhost;uid=root"
        conn = New OdbcConnection(strcon)
        If conn.State = ConnectionState.Closed Then
            conn.Open()
        End If
    End Sub
End Module

PANGGIL MODUL KONEKSI
++++++++++++++++++++++++++++++

Imports System.Data.Odbc
Imports System.Data

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SAMBUNG()
        da = New Odbc.OdbcDataAdapter("select * from cetak_nota", conn)
        ds = New DataSet
        ds.Clear()
        da.Fill(ds, "cetak_nota")
        DataGridView1.DataSource = (ds.Tables("cetak_nota"))

    End Sub
End Class
 Tutorial Selanjunya Free Tuorial lainnya

No comments:

Post a Comment