0% found this document useful (0 votes)
45 views4 pages

Input Database Mysql VB 2010

This document contains code for a Visual Basic 2010 application that connects to a MySQL database. It includes code to connect to the database, insert data into tables, and display data in a datagrid. The code defines classes for forms that allow inputting and viewing data for library members and employees tables. Methods are included to connect to the database, insert records, clear form fields, and load data into the datagrid for display.

Uploaded by

Egi Ginanjar
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)
45 views4 pages

Input Database Mysql VB 2010

This document contains code for a Visual Basic 2010 application that connects to a MySQL database. It includes code to connect to the database, insert data into tables, and display data in a datagrid. The code defines classes for forms that allow inputting and viewing data for library members and employees tables. Methods are included to connect to the database, insert records, clear form fields, and load data into the datagrid for display.

Uploaded by

Egi Ginanjar
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

INPUT Database MySQL VB 2010

Imports [Link]
Public Class Form1
Dim Conn As OdbcConnection
Dim da As OdbcDataAdapter
Dim ds As DataSet
Dim str As String
Dim CMD As OdbcCommand

Private Sub Form1_Load(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Call KondisiAwal()
End Sub
Sub Koneksi()
str = "Driver={MySQL ODBC 5.3 ANSI
Driver};database=DBperpustakaan;server=localhost;uid=root"
Conn = New OdbcConnection(str)
If [Link] = [Link] Then
[Link]()
End If
End Sub

Private Sub Button1_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
If [Link] = "" Or [Link] = "" Or [Link] = "" Or
[Link] = "" Then
MsgBox("Data belum lengkap, Pastikan nomor anggota 6 Digit dan Semua
form terisi")
Exit Sub
Else
Call Koneksi()
Dim simpan As String = "insert into anggota values ('" &

[Link] & "','" & [Link] & "','" & [Link] & "','" &
[Link] & "')"
CMD = New OdbcCommand(simpan, Conn)
[Link]()
MsgBox("Data berhasil di Input", [Link],
"Information")
Call KondisiAwal()
End If
End Sub
Sub KondisiAwal()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = "[Link]"
Koneksi()
da = New OdbcDataAdapter("Select * from anggota ", Conn)
ds = New DataSet
[Link]()
[Link](ds, " anggota ")
[Link] = ([Link]("anggota"))
End Sub
End Class

Imports [Link]
Public Class Form1Petugas
Dim Conn As OdbcConnection

Dim
Dim
Dim
Dim

da As OdbcDataAdapter
ds As DataSet
str As String
CMD As OdbcCommand

Private Sub FormPetugas_Load(ByVal sender As [Link], ByVal e As [Link])


Handles [Link]
Call KondisiAwal()
End Sub
Sub Koneksi()
str = "Driver={MySQL ODBC 5.3 ANSI
Driver};database=Dbperpus;server=localhost;uid=root"
Conn = New OdbcConnection(str)
If [Link] = [Link] Then
[Link]()
End If
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
If [Link] = "" Or [Link] = "" Or [Link] = "" Or [Link] = "" Then
MsgBox("Data belum lengkap, Pastikan kode petugas 6 Digit dan Semua form terisi")
Exit Sub
Else
Call Koneksi()
Dim simpan As String = "insert into petugas values ('" & [Link] & "','" &
[Link] & "','" & [Link] & "','" & [Link] & "')"
CMD = New OdbcCommand(simpan, Conn)
[Link]()
MsgBox("Data berhasil di Input", [Link], "Information")
Call KondisiAwal()
End If
End Sub
Sub KondisiAwal()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
Koneksi()
da = New OdbcDataAdapter("Select * from petugas ", Conn)
ds = New DataSet
[Link]()
[Link](ds, " petugas ")
[Link] = ([Link]("petugas"))
End Sub
Private Sub Button4_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link]()
End Sub
End Class

You might also like