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

Listing Program

The document provides instructions for creating a VB project to access and manage student data from an Access database. It describes designing a form, creating a database called Datasiswa1 with tables containing student information, importing namespaces, and writing code to load and navigate student records, add/edit/delete records, and close the form. The code includes binding controls to display and edit data, handling button clicks for navigation and CRUD operations, and managing the current record position.

Uploaded by

jackoalfarisyi
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)
25 views3 pages

Listing Program

The document provides instructions for creating a VB project to access and manage student data from an Access database. It describes designing a form, creating a database called Datasiswa1 with tables containing student information, importing namespaces, and writing code to load and navigate student records, add/edit/delete records, and close the form. The code includes binding controls to display and edit data, handling button clicks for navigation and CRUD operations, and managing the current record position.

Uploaded by

jackoalfarisyi
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/ 3

Buat Project baru Beri Nama Data_Siswa simpan di D:Praktikum VB/DataSiswa

Buatkan desain Form di bawah ini

Buat Database di Microsoft Acces berinama Datasiswa1 simpan di praktikum VB/Datasiswa/bin


Buat Tabel berisi NIS, Nama, Alamat,Tangga, SPP. Isikan Recordnya.
Imports System.Data.OleDb

Public Class Form1


Dim cn As New OleDbConnection
Dim da As New OleDbDataAdapter("select * from siswa", cn)
Dim dt As New DataTable
Dim ds As New DataSet
Dim cm As CurrencyManager

Private Sub Form1_Load ()


cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\latihan.mdb"
cn.Open()
ds = New DataSet("Pelanggan")
Dim cb As New OleDbCommandBuilder(da)
da.Fill(dt)
TextBox1.DataBindings.Add("text", dt, "nrp")
TextBox2.DataBindings.Add("text", dt, "nama")
TextBox3.DataBindings.Add("text", dt, "alamat")
DateTimePicker1.DataBindings.Add("text", dt, "tgl_lahir")
TextBox4.DataBindings.Add("text", dt, "b_spp")
cn.Close()
cm = CType(Me.BindingContext(dt), CurrencyManager)

posisi()

End Sub

Private Sub posisi()


lblposisi.Text = cm.Position + 1 & " dari " & cm.Count
End Sub
Tombol First
cm.CancelCurrentEdit()
cm.Position = 0
posisi()
End sub

Tombol Back
cm.CancelCurrentEdit()
cm.Position -= 1
posisi()
End sub

Tombol Next
cm.CancelCurrentEdit()
cm.Position += 1
posisi()
End Sub

Tombol Last
cm.CancelCurrentEdit()
cm.Position = cm.Count()
posisi()
End Sub

Tombol Add
cm.EndCurrentEdit()
cm.AddNew()
posisi()
TextBox1.Focus()

Tombol Save
Try
cm.EndCurrentEdit()
da.Update(dt)
posisi()
Catch ex As Exception
MessageBox.Show("Jangan di kosongkan !", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information)
cm.RemoveAt(cm.Position)
posisi()
End Try
End Sub

Tombol Cancel
cm.CancelCurrentEdit()

Tombol Delete
cm.RemoveAt(cm.Position)
da.Update(dt)
posisi()

Tombol Keluar
Me.Close()

You might also like