0% found this document useful (0 votes)
16 views3 pages

Listing Program Mahasiswa

This document contains code for a student listing program in Visual Basic. It defines functions for connecting to a database, displaying student data, adding new students, updating student information, deleting students, and printing reports. The program allows the user to view, edit, and manage a list of students stored in a Microsoft Access database table. It initializes the database connection on loading, and includes buttons to perform common CRUD operations and refresh the data grid displaying student records.

Uploaded by

Toni Wirawan
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)
16 views3 pages

Listing Program Mahasiswa

This document contains code for a student listing program in Visual Basic. It defines functions for connecting to a database, displaying student data, adding new students, updating student information, deleting students, and printing reports. The program allows the user to view, edit, and manage a list of students stored in a Microsoft Access database table. It initializes the database connection on loading, and includes buttons to perform common CRUD operations and refresh the data grid displaying student records.

Uploaded by

Toni Wirawan
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/ 3

Listing Program Mahasiswa

*/ padabagian program delete belumberjalandenganbaik


Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Imports CrystalDecisions.CrystalReports.Engine
PublicClass Form1
Dim conn As OleDbConnection
Dim da As OleDbDataAdapter
Dim CMD As OleDbCommand
Dim ds As DataSet
Dim str AsString
Dim Sql AsString
Dim ubah AsString

Sub Koneksi()
str = "Provider=Microsoft.jet.OLEDB.4.0;data
source=D:\db\mahasiswa.mdb"
conn = New OleDbConnection(str)
If conn.State = ConnectionState.Closed Then
conn.Open()
EndIf
EndSub
Sub TampilkanData()
da = New OleDbDataAdapter("select * from mhs", conn)
ds = New DataSet
da.Fill(ds, "mhs")
DataGridView1.DataSource = ds.Tables("mhs")
EndSub
'menambahkan sub
Sub ButtonBaru()
btnBaru.Enabled = True
btnSimpan.Enabled = True
btnKeluar.Enabled = True
btnHapus.Enabled = True
btnUpdate.Enabled = True
btnCetak.Enabled = True
EndSub
'menambahkan sub
Sub HapusText()
Kode.Text = ""
Nim.Text = ""
Nama.Text = ""
Call ButtonBaru()
EndSub
PrivateSub btnBaru_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBaru.Click

Call HapusText()
Kode.Focus()
EndSub

PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) HandlesMyBase.Load
Call Koneksi()
Call TampilkanData()
EndSub
PrivateSub btnSimpan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSimpan.Click
Sql = "INSERT INTO mhs (Kode,NIM,Nama) values('"& Kode.Text &"','"&
Nim.Text &"','"& Nama.Text &"')"
CMD = New OleDbCommand(Sql, conn)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call TampilkanData()
EndSub
PrivateSub btnKeluar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnKeluar.Click
Me.Close()
EndSub

PrivateSub btnUpdate_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnUpdate.Click
Call Koneksi()
ubah = "Update mhs Set Kode='"& Kode.Text &"', NIM='"& Nim.Text &"'
Nama='"& Nama.Text &"', where Kode='"& Kode.Text &"'"
CMD = New OleDbCommand(ubah, conn)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call TampilkanData()
EndSub

PrivateSub btnHapus_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnHapus.Click
Sql = "DELETE FROM mhs WHERE Kode='"& Kode.Text &"'"
CMD = New OleDbCommand(Sql, conn)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call TampilkanData()
EndSub
EndClass

You might also like