0% found this document useful (0 votes)
14 views2 pages

Modul Koneksi

The document describes a module for connecting to a MySQL database using ODBC in Visual Basic, including a login form that verifies user credentials against the database. It also includes a separate login form that does not require database verification, simply checking if the input fields are filled. The code provides functionality for user feedback on login success or failure and input validation.

Uploaded by

ochexkedang04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Modul Koneksi

The document describes a module for connecting to a MySQL database using ODBC in Visual Basic, including a login form that verifies user credentials against the database. It also includes a separate login form that does not require database verification, simply checking if the input fields are filled. The code provides functionality for user feedback on login success or failure and input validation.

Uploaded by

ochexkedang04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

 Modul Koneksinya

Imports System.Data.Odbc
Imports System.Threading.Thread
Module Module1
Public conn As OdbcConnection
Public da As OdbcDataAdapter
Public ds As DataSet
Public cmd As OdbcCommand
Public rd As OdbcDataReader
Public myDB As String
Public query As String

Public Sub koneksi()


myDB = "Driver={mysql odbc 3.51 Driver};Database=pendudukwureh;server=localhost;uid=root"
conn = New OdbcConnection(myDB)
If conn.State = ConnectionState.Closed Then conn.Open()
End Sub
End Module

 Form Login Pake Database


Imports System.Data.Odbc
Public Class Form1
Sub bersihkan()
GunaTextBox1.Text = ""
GunaTextBox2.Text = ""
GunaTextBox1.Focus()
End Sub
Private Sub GunaButton1_Click(sender As Object, e As EventArgs) Handles GunaButton1.Click
Call koneksi()
cmd = New Odbc.OdbcCommand("select * from admin where username='" &
GunaTextBox1.Text & "'and Password='" & GunaTextBox2.Text & "'", conn)
rd = cmd.ExecuteReader
rd.Read()
If GunaTextBox1.Text = "" Or GunaTextBox2.Text = "" Then
MsgBox("Data Belum Lengkap, Periksa Kembali !!", MsgBoxStyle.Information, "Information")
Call bersihkan()
GunaTextBox1.Focus()
Exit Sub
Else
Call koneksi()
cmd = New Odbc.OdbcCommand("select * from admin where username='" &
GunaTextBox1.Text & "'and Password='" & GunaTextBox2.Text & "'", conn)
rd = cmd.ExecuteReader
rd.Read()

If rd.HasRows Then
MsgBox("Login Berhasil", MsgBoxStyle.Information, "Information Login")
MenuUtamavb.Show()
Else
MsgBox("Login Gagal, Periksa Kembali Username atau Password", MsgBoxStyle.Information,
"Information Login")
Call bersihkan()
GunaTextBox1.Focus()
End If
End If
End Sub
End Class

 Form Login Tanpa Database

Public Class Form1

Private Sub GunaButton1_Click(sender As Object, e As EventArgs) Handles GunaButton1.Click


If GunaTextBox1.Text = "" Or GunaTextBox2.Text = "" Then
MsgBox("Data Belum Lengkap, Periksa Kebali !!", MsgBoxStyle.Information, "Information")
GunaTextBox1.Focus()
Exit Sub
Else
MenuUtamavb.Show()
End If
End Sub
End Class

You might also like