SlideShare a Scribd company logo
1 of 4
LATIHAN CRUD VB2010 DENGAN MS. ACCESS 2007 (BY: DIK-DIK.COM)
1. Buat database denganMs. Accces 2007, sbb:
Simpandi projectini,caranyaklikkananpada nama project:
Masuk ke FolderBin  Debug,masukandatabase ke folderini.
2. Buat Module Koneksi
KlikmenuProject  AddModule,ketikankodingberikutini:
Imports System.Data.OleDb
Module Module1
Public Conn As OleDbConnection
Public da As OleDbDataAdapter
Public ds As DataSet
Public cmd As OleDbCommand
Public rd As OleDbDataReader
Public Sub Koneksi()
Conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=PTABC.ACCDB")
Conn.Open()
End Sub
End Module
3. Buat tampilan Design sbb:
Object Properti Value
Form Name Pegawai
Textbox1 Name txtKOPEG
Textbox2 Name txtNAPEG
Textbox3 Name txtUsia
Button1 Name btnNew
Text NEW
Button2 Name btnSave
Text SAVE
Button3 Name btnEdit
Text EDIT
Button4 Name btnDelete
Text DELETE
Button5 Name btnExit
Text EXIT
DataGridView Name DGV
Radiobutton1 Name OPTJK
RadioButton2 Name OPTJK2
Berikutkodingnyasbb:
Imports System.Data.OleDb
Public Class Pegawai
Dim JK As String
Sub tampilkan()
da = New OleDbDataAdapter("select * from PEGAWAI", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "PEGAWAI")
DGV.DataSource = (ds.Tables("PEGAWAI"))
DGV.ReadOnly = True
End Sub
Sub kosongkan()
txtKOPEG.Enabled = True
txtNAPEG.Enabled = True
txtUsia.Enabled = True
txtNAPEG.Text = ""
txtUsia.Text = ""
txtKOPEG.Focus()
End Sub
Private Sub Pegawai_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Call Koneksi()
Call tampilkan()
txtKOPEG.Enabled = False
txtNAPEG.Enabled = False
txtUsia.Enabled = False
btnDelete.Enabled = False
btnEdit.Enabled = False
btnSave.Enabled = False
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnNew.Click
Call kosongkan()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnDelete.Click
If txtKOPEG.Text = "" Then
MsgBox("Isi kode Pegawai terlebih dahulu")
txtKOPEG.Focus()
Exit Sub
Else
If MessageBox.Show("Yakin akan dihapus..?", "", MessageBoxButtons.YesNo) =
Windows.Forms.DialogResult.Yes Then
cmd = New OleDbCommand("delete * from PEGAWAI where KOPEG = '" &
txtKOPEG.Text & "'", Conn)
cmd.ExecuteNonQuery()
Call kosongkan()
Call tampilkan()
Else
Call kosongkan()
End If
End If
End Sub
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnEdit.Click
If txtKOPEG.Text = "" Then
MsgBox("Isi kode Pegawai terlebih dahulu")
txtNAPEG.Focus()
Exit Sub
Else
If MessageBox.Show("Yakin akan di Edit..?", "", MessageBoxButtons.YesNo) =
Windows.Forms.DialogResult.Yes Then
cmd = New OleDbCommand("update PEGAWAI set NAPEG ='" & txtNAPEG.Text & "',
USIA =" & txtUsia.Text & ",JK='" & JK & "' where KOPEG = '" & txtKOPEG.Text & "'", Conn)
cmd.ExecuteNonQuery()
txtKOPEG.Text = ""
Call kosongkan()
Call tampilkan()
Else
Call kosongkan()
End If
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnExit.Click
If MessageBox.Show("Yakin akan keluar..?", "", MessageBoxButtons.YesNo) =
Windows.Forms.DialogResult.Yes Then
End
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSave.Click
Dim sqltambah As String = "insert into PEGAWAI(KOPEG,NAPEG,USIA, JK) values " & _
"('" & txtKOPEG.Text & "','" & txtNAPEG.Text & "'," & txtUsia.Text & ",'" &
JK & "')"
cmd = New OleDbCommand(sqltambah, Conn)
cmd.ExecuteNonQuery()
txtKOPEG.Text = ""
Call tampilkan()
Call kosongkan()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Form2.Show()
End Sub
Private Sub OptJK_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OptJK.CheckedChanged
If OptJK.Enabled = True Then
JK = "L"
End If
End Sub
Private Sub optJK2_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles optJK2.CheckedChanged
If optJK2.Enabled = True Then
JK = "P"
End If
End Sub
Private Sub txtKOPEG_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtKOPEG.KeyPress
Dim x As String
If e.KeyChar = Chr(13) Then
cmd = New OleDbCommand("select * from Pegawai where KOPEG='" & txtKOPEG.Text &
"'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows = True Then
txtNAPEG.Text = rd.GetString(1)
txtUsia.Text = rd.GetValue(2)
x = rd.GetString(3)
If x = "L" Then
OptJK.Checked = True
ElseIf x = "P" Then
optJK2.Checked = True
End If
txtNAPEG.Focus()
btnSave.Enabled = False
btnEdit.Enabled = True
btnDelete.Enabled = True
Else
Call kosongkan()
txtNAPEG.Focus()
btnSave.Enabled = True
End If
End If
End Sub
End Class

More Related Content

What's hot

DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERDarwin Durand
 
Codes
CodesCodes
CodesOSit3
 
Vb database connections
Vb database connectionsVb database connections
Vb database connectionsTharsikan
 
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)Jannat Ruma
 
Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Kevin Octavian
 
Lenguaje de programación
Lenguaje de programaciónLenguaje de programación
Lenguaje de programaciónlhaylha moran
 
Url&doc html
Url&doc htmlUrl&doc html
Url&doc htmlakila m
 
Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3Helmita putri
 
Linked In Presentation
Linked In PresentationLinked In Presentation
Linked In Presentationapweir12
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
Ext GWT 3.0 Layouts
Ext GWT 3.0 LayoutsExt GWT 3.0 Layouts
Ext GWT 3.0 LayoutsSencha
 
State management in asp
State management in aspState management in asp
State management in aspIbrahim MH
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6Andy Sharman
 
 Exchange migration of legacy public folders to 2013
 Exchange   migration of legacy public folders to 2013 Exchange   migration of legacy public folders to 2013
 Exchange migration of legacy public folders to 2013Gary Jackson
 
Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extensionRebecca Peltz
 

What's hot (20)

DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
Codes
CodesCodes
Codes
 
Vb database connections
Vb database connectionsVb database connections
Vb database connections
 
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)
 
Backup And Restore NGL Database
Backup And Restore NGL DatabaseBackup And Restore NGL Database
Backup And Restore NGL Database
 
Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1
 
Lenguaje de programación
Lenguaje de programaciónLenguaje de programación
Lenguaje de programación
 
PHP with MYSQL
PHP with MYSQLPHP with MYSQL
PHP with MYSQL
 
Url&doc html
Url&doc htmlUrl&doc html
Url&doc html
 
Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3
 
Linked In Presentation
Linked In PresentationLinked In Presentation
Linked In Presentation
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
Ext GWT 3.0 Layouts
Ext GWT 3.0 LayoutsExt GWT 3.0 Layouts
Ext GWT 3.0 Layouts
 
Quanlycanbo
QuanlycanboQuanlycanbo
Quanlycanbo
 
State management in asp
State management in aspState management in asp
State management in asp
 
Active Record
Active RecordActive Record
Active Record
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6
 
 Exchange migration of legacy public folders to 2013
 Exchange   migration of legacy public folders to 2013 Exchange   migration of legacy public folders to 2013
 Exchange migration of legacy public folders to 2013
 
Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extension
 

Viewers also liked

3Com JD008A
3Com JD008A3Com JD008A
3Com JD008Asavomir
 
3Com JE015A
3Com JE015A3Com JE015A
3Com JE015Asavomir
 
Actividad no. 8 carlos h. muñoz.
Actividad no. 8 carlos h. muñoz.Actividad no. 8 carlos h. muñoz.
Actividad no. 8 carlos h. muñoz.charleshamil
 
3Com 3C17512
3Com 3C175123Com 3C17512
3Com 3C17512savomir
 
Fsmith 2017 02_09_09_29_27 (1)
Fsmith 2017 02_09_09_29_27 (1)Fsmith 2017 02_09_09_29_27 (1)
Fsmith 2017 02_09_09_29_27 (1)megansaunders99
 
A domain specific language for configurable traceability analysis
A domain specific language for configurable traceability analysisA domain specific language for configurable traceability analysis
A domain specific language for configurable traceability analysisHendrik Bünder
 
Slow Down Online Guessing Attacks with Device Cookies
Slow Down Online Guessing Attacks with Device CookiesSlow Down Online Guessing Attacks with Device Cookies
Slow Down Online Guessing Attacks with Device CookiesAnton Dedov
 
Circuitos eléctricos en serie
Circuitos eléctricos en serieCircuitos eléctricos en serie
Circuitos eléctricos en seriemaría torrez
 
Proyecto jelitza moreira
Proyecto jelitza moreiraProyecto jelitza moreira
Proyecto jelitza moreiraGinzo17
 

Viewers also liked (15)

Slade share
Slade shareSlade share
Slade share
 
5.05 eng
5.05 eng5.05 eng
5.05 eng
 
3Com JD008A
3Com JD008A3Com JD008A
3Com JD008A
 
Браслеты Пандора
Браслеты ПандораБраслеты Пандора
Браслеты Пандора
 
3Com JE015A
3Com JE015A3Com JE015A
3Com JE015A
 
Actividad no. 8 carlos h. muñoz.
Actividad no. 8 carlos h. muñoz.Actividad no. 8 carlos h. muñoz.
Actividad no. 8 carlos h. muñoz.
 
Sistemas Operativos
Sistemas Operativos Sistemas Operativos
Sistemas Operativos
 
3Com 3C17512
3Com 3C175123Com 3C17512
3Com 3C17512
 
Fsmith 2017 02_09_09_29_27 (1)
Fsmith 2017 02_09_09_29_27 (1)Fsmith 2017 02_09_09_29_27 (1)
Fsmith 2017 02_09_09_29_27 (1)
 
Talleres didácticos de arqueología
Talleres didácticos de arqueologíaTalleres didácticos de arqueología
Talleres didácticos de arqueología
 
Ken collis
Ken collisKen collis
Ken collis
 
A domain specific language for configurable traceability analysis
A domain specific language for configurable traceability analysisA domain specific language for configurable traceability analysis
A domain specific language for configurable traceability analysis
 
Slow Down Online Guessing Attacks with Device Cookies
Slow Down Online Guessing Attacks with Device CookiesSlow Down Online Guessing Attacks with Device Cookies
Slow Down Online Guessing Attacks with Device Cookies
 
Circuitos eléctricos en serie
Circuitos eléctricos en serieCircuitos eléctricos en serie
Circuitos eléctricos en serie
 
Proyecto jelitza moreira
Proyecto jelitza moreiraProyecto jelitza moreira
Proyecto jelitza moreira
 

Similar to CRUD VB2010

Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaYusman Kurniadi
 
Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202Mahmoud Samir Fayed
 
Ebooktiketkapal
EbooktiketkapalEbooktiketkapal
Ebooktiketkapaldhi her
 
The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196Mahmoud Samir Fayed
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บทMareenaHahngeh
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บทMareenaHahngeh
 
The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212Mahmoud Samir Fayed
 
A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)Alan Manifold
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01mafv1976
 
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdfImports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdffantabulustredingco
 
The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180Mahmoud Samir Fayed
 

Similar to CRUD VB2010 (20)

Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhana
 
Ditec esoft C# project
Ditec esoft C# projectDitec esoft C# project
Ditec esoft C# project
 
Ditec esoft C# project
Ditec esoft C# project Ditec esoft C# project
Ditec esoft C# project
 
Inventory management
Inventory managementInventory management
Inventory management
 
The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202The Ring programming language version 1.8 book - Part 34 of 202
The Ring programming language version 1.8 book - Part 34 of 202
 
Ebooktiketkapal
EbooktiketkapalEbooktiketkapal
Ebooktiketkapal
 
QTP
QTPQTP
QTP
 
The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196The Ring programming language version 1.7 book - Part 32 of 196
The Ring programming language version 1.7 book - Part 32 of 196
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บท
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บท
 
The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88
 
The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212The Ring programming language version 1.10 book - Part 37 of 212
The Ring programming language version 1.10 book - Part 37 of 212
 
A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01
 
ALL NEW OOP 2014
ALL NEW OOP 2014ALL NEW OOP 2014
ALL NEW OOP 2014
 
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdfImports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdf
 
The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180
 
Qtp test
Qtp testQtp test
Qtp test
 

More from Achmad Sidik

Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)Achmad Sidik
 
Menghitung Luas Bangunan dengan C++
Menghitung Luas Bangunan dengan C++Menghitung Luas Bangunan dengan C++
Menghitung Luas Bangunan dengan C++Achmad Sidik
 
Latihan C++ menggunakan setConsoleCursorPosition
Latihan C++ menggunakan setConsoleCursorPositionLatihan C++ menggunakan setConsoleCursorPosition
Latihan C++ menggunakan setConsoleCursorPositionAchmad Sidik
 
Membuat Aplikasi dengan C++
Membuat Aplikasi dengan C++Membuat Aplikasi dengan C++
Membuat Aplikasi dengan C++Achmad Sidik
 
Program menghitung angka genap dengan C++
Program menghitung angka genap dengan C++Program menghitung angka genap dengan C++
Program menghitung angka genap dengan C++Achmad Sidik
 
CRUD dengan asp classic
CRUD dengan asp classicCRUD dengan asp classic
CRUD dengan asp classicAchmad Sidik
 

More from Achmad Sidik (7)

Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)
 
goto dengan C++
goto dengan C++goto dengan C++
goto dengan C++
 
Menghitung Luas Bangunan dengan C++
Menghitung Luas Bangunan dengan C++Menghitung Luas Bangunan dengan C++
Menghitung Luas Bangunan dengan C++
 
Latihan C++ menggunakan setConsoleCursorPosition
Latihan C++ menggunakan setConsoleCursorPositionLatihan C++ menggunakan setConsoleCursorPosition
Latihan C++ menggunakan setConsoleCursorPosition
 
Membuat Aplikasi dengan C++
Membuat Aplikasi dengan C++Membuat Aplikasi dengan C++
Membuat Aplikasi dengan C++
 
Program menghitung angka genap dengan C++
Program menghitung angka genap dengan C++Program menghitung angka genap dengan C++
Program menghitung angka genap dengan C++
 
CRUD dengan asp classic
CRUD dengan asp classicCRUD dengan asp classic
CRUD dengan asp classic
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

CRUD VB2010

  • 1. LATIHAN CRUD VB2010 DENGAN MS. ACCESS 2007 (BY: DIK-DIK.COM) 1. Buat database denganMs. Accces 2007, sbb: Simpandi projectini,caranyaklikkananpada nama project: Masuk ke FolderBin  Debug,masukandatabase ke folderini. 2. Buat Module Koneksi KlikmenuProject  AddModule,ketikankodingberikutini: Imports System.Data.OleDb Module Module1 Public Conn As OleDbConnection Public da As OleDbDataAdapter Public ds As DataSet Public cmd As OleDbCommand Public rd As OleDbDataReader Public Sub Koneksi() Conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=PTABC.ACCDB") Conn.Open() End Sub End Module
  • 2. 3. Buat tampilan Design sbb: Object Properti Value Form Name Pegawai Textbox1 Name txtKOPEG Textbox2 Name txtNAPEG Textbox3 Name txtUsia Button1 Name btnNew Text NEW Button2 Name btnSave Text SAVE Button3 Name btnEdit Text EDIT Button4 Name btnDelete Text DELETE Button5 Name btnExit Text EXIT DataGridView Name DGV Radiobutton1 Name OPTJK RadioButton2 Name OPTJK2 Berikutkodingnyasbb: Imports System.Data.OleDb Public Class Pegawai Dim JK As String Sub tampilkan() da = New OleDbDataAdapter("select * from PEGAWAI", Conn) ds = New DataSet ds.Clear() da.Fill(ds, "PEGAWAI") DGV.DataSource = (ds.Tables("PEGAWAI")) DGV.ReadOnly = True End Sub Sub kosongkan() txtKOPEG.Enabled = True txtNAPEG.Enabled = True txtUsia.Enabled = True txtNAPEG.Text = "" txtUsia.Text = "" txtKOPEG.Focus() End Sub Private Sub Pegawai_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call Koneksi() Call tampilkan() txtKOPEG.Enabled = False txtNAPEG.Enabled = False txtUsia.Enabled = False btnDelete.Enabled = False btnEdit.Enabled = False btnSave.Enabled = False End Sub Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click Call kosongkan() End Sub Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click If txtKOPEG.Text = "" Then MsgBox("Isi kode Pegawai terlebih dahulu")
  • 3. txtKOPEG.Focus() Exit Sub Else If MessageBox.Show("Yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then cmd = New OleDbCommand("delete * from PEGAWAI where KOPEG = '" & txtKOPEG.Text & "'", Conn) cmd.ExecuteNonQuery() Call kosongkan() Call tampilkan() Else Call kosongkan() End If End If End Sub Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click If txtKOPEG.Text = "" Then MsgBox("Isi kode Pegawai terlebih dahulu") txtNAPEG.Focus() Exit Sub Else If MessageBox.Show("Yakin akan di Edit..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then cmd = New OleDbCommand("update PEGAWAI set NAPEG ='" & txtNAPEG.Text & "', USIA =" & txtUsia.Text & ",JK='" & JK & "' where KOPEG = '" & txtKOPEG.Text & "'", Conn) cmd.ExecuteNonQuery() txtKOPEG.Text = "" Call kosongkan() Call tampilkan() Else Call kosongkan() End If End If End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click If MessageBox.Show("Yakin akan keluar..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then End End If End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim sqltambah As String = "insert into PEGAWAI(KOPEG,NAPEG,USIA, JK) values " & _ "('" & txtKOPEG.Text & "','" & txtNAPEG.Text & "'," & txtUsia.Text & ",'" & JK & "')" cmd = New OleDbCommand(sqltambah, Conn) cmd.ExecuteNonQuery() txtKOPEG.Text = "" Call tampilkan() Call kosongkan() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Form2.Show() End Sub Private Sub OptJK_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptJK.CheckedChanged If OptJK.Enabled = True Then JK = "L" End If End Sub
  • 4. Private Sub optJK2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optJK2.CheckedChanged If optJK2.Enabled = True Then JK = "P" End If End Sub Private Sub txtKOPEG_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtKOPEG.KeyPress Dim x As String If e.KeyChar = Chr(13) Then cmd = New OleDbCommand("select * from Pegawai where KOPEG='" & txtKOPEG.Text & "'", Conn) rd = cmd.ExecuteReader rd.Read() If rd.HasRows = True Then txtNAPEG.Text = rd.GetString(1) txtUsia.Text = rd.GetValue(2) x = rd.GetString(3) If x = "L" Then OptJK.Checked = True ElseIf x = "P" Then optJK2.Checked = True End If txtNAPEG.Focus() btnSave.Enabled = False btnEdit.Enabled = True btnDelete.Enabled = True Else Call kosongkan() txtNAPEG.Focus() btnSave.Enabled = True End If End If End Sub End Class