Pertama, buka Ms.SQL server dan buat database mahasiswa (dbmahasiswa)
kemudian buat tabel mahasiswa (tbmahasiswa) dan isikan 2 data.
Ms. Visual Studio 2010
buka aplikasi tersebut, pilih Data >> Add New -
Data Source >> Database - Next >> Dataset - Next >> New Connection
pilih Microsoft SQL Server> continue
Pada bagian Server Name, pilih server yang tersedia. Jika tidak bisa kembali ke
SQL Server dan sorot nama
server (pilih Connect lalu copy nama server tersebut).
Pada Log on to the
server pilih Use Windows Authentication. Dan masukkan
dbmahasiswa. Lalu Test
Connection, jika sukses maka telah siap dikonekkan.. Selanjutnya pilih OK
finish dan kembali ke ms.visual basic
Pada menu Data pilih Show Data Sources.
drag semua form
dan buat desainnya.
contoh :
dengan kode program
Public Class Form1
Private Sub TbmahasiswaBindingNavigatorSaveItem_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Me.Validate()
Me.TbmahasiswaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DbmahasiswaDataSet)
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
'TODO: This
line of code loads data into the 'DbmahasiswaDataSet.tbmahasiswa' table. You
can move, or remove it, as needed.
Me.TbmahasiswaTableAdapter.Fill(Me.DbmahasiswaDataSet.tbmahasiswa)
End Sub
Private Sub NAMALabel_Click(ByVal
sender As Object,
ByVal e As EventArgs)
Throw New NotImplementedException
End Sub
>>Untuk Button pertama ##
Private Sub Button1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs)Handles
Button1.Click
Me.TbmahasiswaBindingSource.MoveFirst()
End Sub
>>Untuk Button Sebelumnya
Private Sub Button2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button2.Click
Me.TbmahasiswaBindingSource.MovePrevious()
End Sub
>>Untuk Button Selanjutnya
Private Sub Button3_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button3.Click
Me.TbmahasiswaBindingSource.MoveNext()
End Sub
>>Untuk Button Terakhir
Private Sub Button4_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button4.Click
Me.TbmahasiswaBindingSource.MoveLast()
End Sub
>>Untuk Button tambah
Private Sub bttambah_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
bttambah.Click
Me.TbmahasiswaBindingSource.AddNew()
NIMTextBox.Focus()
TGL_LAHIRDateTimePicker.ResetText()
End Sub
>>Untuk Button hapus
Private Sub bthapus_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
bthapus.Click
If
MsgBox("Apakah Anda Yakin ?",
vbYesNo + vbQuestion + vbDefaultButton2, "Delete")
= vbYes Then
Me.TbmahasiswaBindingSource.RemoveCurrent()
End If
End Sub
>>Untuk Button simpan
Private Sub Btsimpan_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Btsimpan.Click
Me.Validate()
Me.TbmahasiswaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DbmahasiswaDataSet)
End Sub
>>Untuk Button cari
Private Sub btcari_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
btcari.Click
If
(TbmahasiswaBindingSource.Find("NIM",
TextBox1.Text)) > -1 Then
MsgBox("Data
berhasil ditemukan")
Else
MsgBox("Data
tidak berhasil ditemukan")
End If
End Sub
>>Untuk Button Filter
Private Sub Btfilter_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Btfilter.Click
Dim
Mencari As String
Mencari = InputBox("Masukkan Jurusan Yang Di Cari", "Filter ...")
End Sub
>>Untuk Button Keluar
Private Sub Btkeluar_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Btkeluar.Click
Me.Close()
End Sub
End Class