Selamat pagi,siang,sore,malam buat kk yg lagi jalan-jalan nyari makalah buat tugas. Kali ini saya mau sedikit share materi kuliah Pemrograman Visual tentang Menghubungkan SQL server 2005 kedalam Visual Basic 2010.
Maksudnya adalah kita membuat program atau database diSQL Server 2005 kemudian kita connekin ke Visual Basic 2010.
Public Class Form1
Private Sub
TbmhsiswaBindingNavigatorSaveItem_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
TbmhsiswaBindingNavigatorSaveItem.Click
Me.Validate()
Me.TbmhsiswaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DbmhsiswaDataSet)
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
'DbmhsiswaDataSet.tbmhsiswa' table. You can move, or remove it, as needed.
Me.TbmhsiswaTableAdapter.Fill(Me.DbmhsiswaDataSet.tbmhsiswa)
End Sub
*Untuk mengedit*
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim ketemu As Integer
ketemu = TbmhsiswaBindingSource.Find("nim",
TextBox1.Text)
If ketemu >= 0 Then
MsgBox("Nim sudah terpakai",
0 + 16, "perhatian")
TextBox1.Text = " "
TextBox1.Focus()
Else
TbmhsiswaBindingSource.AddNew()
NimTextBox.Text = TextBox1.Text
NimTextBox.Focus()
End If
End Sub
* botton untuk melihat data sebelumnya*
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TbmhsiswaBindingSource.MovePrevious()
End Sub
* button untuk melihat data paling akhir*
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
TbmhsiswaBindingSource.MoveLast()
End Sub
*Button untuk melihat data sesudahnya*
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
TbmhsiswaBindingSource.MoveNext()
End Sub
*batton untuk melihat data paling awal/pertama*
Private Sub Button5_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Button5.Click
TbmhsiswaBindingSource.MoveFirst()
End Sub
*button untuk menyimpan*
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
Me.Validate()
Me.TbmhsiswaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DbmhsiswaDataSet)
End Sub
*button untuk menghapus*
Private Sub
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button7.Click
If MsgBox("Apakah
Anda Yakin ?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete") = vbYes Then
Me.TbmhsiswaBindingSource.RemoveCurrent()
End If
End Sub
*button untuk filter*
Private Sub
Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button8.Click
Dim Mencari As Integer
Mencari = InputBox("Masukkan NIM yang
Anda Cari", "Filter ...")
End Sub
*button untuk menambah data*
Private Sub
Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button9.Click
Me.TbmhsiswaBindingSource.AddNew()
NimTextBox.Focus()
TgllahirDateTimePicker.ResetText()
End Sub
*button untuk mencari*
Private Sub
Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button10.Click
If (TbmhsiswaBindingSource.Find("NIM", TextBox1.Text)) > -1 Then
MsgBox("Data berhasil ditemukan")
Else
MsgBox("Data tidak berhasil
ditemukan")
End If
End Sub
*batton untuk keluar*
Private Sub
Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button11.Click
End
End Sub
End Class