#Post Title #Post Title #Post Title
Rabu, 13 Juni 2012

TUGAS VIDEO TUTORIAL

1. Video tutorial cara menampilkan data yang telah direcord ke VB dan Mencari Record Data Tersebut


2. Video tutorial cara menambah dan mengubah data pada Visual basic



3. Video tutorial cara menghapus data dan keluar dari program




sekian
terimakasih
[ Read More ]
Jumat, 01 Juni 2012

TUTORIAL MENGUBAH RECORD DATA

Kali ini saya akan membuat toturial bagaimana cara mengubah data yang telah direcord, seperti biasa buatlah database pada Mysql 




Kemudian pada VB buatlah 3 Form Seperti digambar

Rumus pada Form 1

Imports MySql.Data.MySqlClient
Public Class FMhs
Dim MyCon As New MySqlConnection("Server=localhost;User id=root;Password=1111;Database=akademik")
Private Sub FMhs_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyAdapter As New MySqlDataAdapter("Select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
End Sub

Private Sub txtcari_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcari.KeyPress
If e.KeyChar = vbCr Then
If cmbcari.Text = "NPM" Then
Dim MyAdapter As New MySqlDataAdapter("select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa Where npm Like '%" & txtcari.Text & "%'", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf cmbcari.Text = "NAMA" Then
Dim MyAdapter As New MySqlDataAdapter("select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa Where nama Like '%" & txtcari.Text & "%'", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf cmbcari.Text = "JURUSAN" Then
Dim MyAdapter As New MySqlDataAdapter("select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa Where jurusan Like '%" & txtcari.Text & "%'", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf cmbcari.Text = "TANGGAL LAHIR" Then
Dim MyAdapter As New MySqlDataAdapter("select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa Where tgllahir Like '%" & txtcari.Text & "%'", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf cmbcari.Text = "JENIS KELAMIN" Then
Dim MyAdapter As New MySqlDataAdapter("select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa Where jkel Like '%" & txtcari.Text & "%'", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf cmbcari.Text = "ALAMAT" Then
Dim MyAdapter As New MySqlDataAdapter("select NPM,nama,jurusan,tgllahir,jkel,alamat from mahasiswa Where alamat Like '%" & txtcari.Text & "%'", MyCon)
Dim MyDataTbl As New DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
End If
End If
End Sub

Private Sub btntambah_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntambah.Click
btntambah.Focus()
FMahasiswa_Tambah.ShowDialog()
Me.Close()
End Sub

Private Sub btnkeluar_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
If MsgBox("YAKINMAUKELUAR?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Konfirmasi") = MsgBoxResult.Yes Then
End
End If
End Sub
Private Sub btnubah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnubah.Click
FMahasiswa_Ubah.TextBox1.Enabled = False
FMahasiswa_Ubah.TextBox1.Text = DGV.SelectedCells(0).Value
FMahasiswa_Ubah.TextBox2.Text = DGV.SelectedCells(1).Value
FMahasiswa_Ubah.TextBox3.Text = DGV.SelectedCells(2).Value
FMahasiswa_Ubah.DateTimePicker1.Text = DGV.SelectedCells(3).Value
If DGV.SelectedCells(4).Value = "laki-laki" Then
FMahasiswa_Ubah.RadioButton1.Checked = True
ElseIf DGV.SelectedCells(4).Value = "perempuan" Then
FMahasiswa_Ubah.RadioButton2.Checked = True
End If
FMahasiswa_Ubah.TextBox6.Text = DGV.SelectedCells(5).Value
FMahasiswa_Ubah.ShowDialog()
End Sub

Private Sub DGV_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV.CellContentClick

End Sub
End Class



Imports MySql.Data.MySqlClient
Public Class FMahasiswa_Ubah
Dim MyCon As New MySqlConnection("Server=localhost;User id=root;Password=1111;Database=akademik")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tgl As String
tgl = Format(DateTimePicker1.Value, "yyyy/MM/dd")
Dim rdb As String
If RadioButton1.Checked = True Then
rdb = "Laki-Laki"
Else
rdb = "Perempuan"
End If
MyCon.Open()
Dim StrSQL As String = "update Mahasiswa set NPM = '" & TextBox1.Text & "',nama = '" & TextBox2.Text & "',jurusan = '" & TextBox3.Text & "',tgllahir = '" & tgl & "',jkel ='" & rdb & "',alamat ='" & TextBox6.Text & "' where NPM ='" & TextBox1.Text & "'"
Dim mycmd As New MySqlCommand(StrSQL, MyCon)
Dim rdr As MySqlDataReader = mycmd.ExecuteReader
MyCon.Close()
Me.Close()
End Sub

Private Sub FMahasiswa_Ubah_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class



rumus pada form tambah
Imports MySql.Data.MySqlClient
Public Class FMahasiswa_Tambah
Dim MyCon As New MySqlConnection("Server=localhost;User id=root;Password=1111;Database=akademik")

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tgl As String
tgl = Format(DateTimePicker1.Value, "yyyy/MM/dd")
Dim rdb As String
If RadioButton1.Checked = True Then
rdb = "Laki-Laki"
Else
rdb = "Perempuan"
End If
MyCon.Open()
Dim StrSQL As String = "Insert Into Mahasiswa (NPM,nama,jurusan,tgllahir,jkel,alamat) values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & tgl & "','" & rdb & "','" & TextBox6.Text & "')"
Dim mycmd As New MySqlCommand(StrSQL, MyCon)
Dim rdr As MySqlDataReader = mycmd.ExecuteReader
Me.Close()
End Sub

Private Sub FMahasiswa_Tambah_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class


Saat anda memilih salah satu column secara keseluruhan dan menekan tomboh ubah maka akan keluar form brk :


Perbaiki datanya kemudian tekan ubah





[ Read More ]
 
 

Labels