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

Database Tiara 2

This document contains code for a database application in Visual Basic. It includes two forms - Form1 and Form2. Form1 contains controls and buttons to insert, update, delete and display data in a DataGridView from a table called "mahasiswa" in a MySQL database. Form2 displays data from the "matakuliah" table. A Module contains a method to execute queries and populate a DataGridView with the results.

Uploaded by

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

Database Tiara 2

This document contains code for a database application in Visual Basic. It includes two forms - Form1 and Form2. Form1 contains controls and buttons to insert, update, delete and display data in a DataGridView from a table called "mahasiswa" in a MySQL database. Form2 displays data from the "matakuliah" table. A Module contains a method to execute queries and populate a DataGridView with the results.

Uploaded by

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

Nama : Tiara Dwi Lestari

Nim : 112210081
Kelas : 3B

Tugas Database 2

• Form 1
Imports MySql.Data.MySqlClient
Public Class Form1
Dim f2 As Form2 = New Form2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
lihat()
ComboBox1.Items.Add("laki-laki")
ComboBox1.Items.Add("perempuan")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
f2.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
view("insert into mahasiswa values('" & TextBox1.Text & "', " & TextBox2.Text &
", '" & TextBox3.Text & "','" & ComboBox1.Text & "')", DataGridView1)
lihat()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
view("update mahasiswa set nama='" & TextBox2.Text & "',jk='" & ComboBox1.Text &
"', kelas ='" & TextBox3.Text & "' where nim= " & TextBox1.Text & "", DataGridView1)
lihat()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
view("delete from mahasiswa where nim =" & TextBox1.Text & "", DataGridView1)
lihat()
End Sub
Sub lihat()
view("select * from mahasiswa", DataGridView1)
End Sub
End Class

• Form 2
Imports MySql.Data.MySqlClient
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
view("select * from matakuliah", DataGridView1)
End Sub
End Class
• Module

Imports MySql.Data.MySqlClient
Module Module1
Public con As MySqlConnection
Public db As MySqlDataAdapter
Public ds As DataSet
Sub view(ByVal a As String, ByVal b As DataGridView)
Try
con = New MySqlConnection("server=localhost; user=root; pass=;
database=tiaradwi")
db = New MySqlDataAdapter
ds = New DataSet
db.Fill(ds)
b.DataSource = ds
b.DataMember = ds.Tables(0).ToString
Catch ex As Exception
End Try
End Sub
End Module

You might also like