CRUD Visual Basic 6.0 Terhubung Dengan Database

Bismillahirahmanirahim ~
Asslamualaikuuumm (^-^) ..

Pada postingan sebelumnya kita telah belajar untuk menghubungkan VB 6.0 dengan database (Ms. Access) tapi dengan secara manual, nah kali ini kita akan membuat program yang terhubung dengan database menggunakan source code. Yokkk kita mulai ..

Persiapkan databasenya dulu yaaa J
1.       Nama database: DataBase.mdb
2.       Nama tabel: admin
3.       Fieldnya: no, id_admin, nama_admin, user_name, password

Kalo udah, buka MS. VB 6.0 ..
Komponen yang dibutuhkan:
1.       Microsoft ADO Data Control 6.0 (OLEDB)
2.       Microsoft DataGrid Control 6.0 (OLEDB)

Pada project1, kita buat:
1.       1 module
2.       3 form

Module 1

Module1 dibuat sebagai variabel global yang dapat diakses pada semua form. Cara buatnya:



Yukkk ketik source codenya:



Form1

Tampilan pertama pada program, isinya tempat menginput username dan password, dan akan menuju form berikutnya jika tpmbol logiun diklik, tombol login mengirim inputan dan mencocokan ke databasenya ..

Design:



Object
Properties
Event
Adodc1
Visible: False

CommandButton1
Caption: X
Click()
CommandButton2
Name: cmdSubmit
Caption: &LOGIN
Click()
Form1
StartUpPosition: 1 - CenterOwner
BorderStyle: 0 - None
Load()
Label1
BackColor: &H00FFFF00&

Text1
Name: txtUser
Caption: Username
GotFocus()
LostFocus()
Text2
Name: txtPassword
Caption: Password
GotFocus()
LostFocus()
Setelah design dibuat, selanjutnya kita view kode pada setiap event seperti tabel diatas J
<ini kodenya>



<lanjutan>



Form 2

Tampilan setelah tombol cmdSubmit diklik, dan setelah inputan nama dan password yang cocok denngan salah satu isi di database.

Design:


Object
Properties
Event
Adodc1
Visible: False

CommandButton1
Caption: &ADD
Click()
CommandButton2
Caption: &LOGOUT
Click()
CommandButton3
Caption: &DELETE
Click()
DataGrid1


Form2
StartUpPosition: 1 - CenterOwner
BorderStyle: 0 - None
Activate()

Setelah design dibuat, selanjutnya kita view kode pada setiap event seperti tabel diatas
J

<ini kodenya>



Form 3

Tampilan setelah tombol CommandButton1 (Caption: &ADD) diklik.

Design:



Object
Properties
Event
Adodc1
Visible: False

CommandButton1
Caption: Tambah
Click()
CommandButton2
Caption: Batal
Click()
Form3
StartUpPosition: 1 - CenterOwner
BorderStyle: 0 - None
Load()
Label1
Caption: ID

Label2
Caption: Nama

Label3
Caption: Username

Label4
Caption: Password

Label5
Caption: Tambah data

Text1

GotFocus()
LostFocus()
Text2

GotFocus()
LostFocus()
Text3

GotFocus()
LostFocus()
Text4

GotFocus()
LostFocus()

Setelah design dibuat, selanjutnya kita view kode pada setiap event seperti tabel diatas J

<ini kodenya>


<lanjutan>



<lanjutan>



Selesai yeyeye lalalala yeyeyyee ~(^-^)~


Untuk kode lengkapnya download di sini

Komentar

Postingan populer dari blog ini

Siapa Pemimpin Merdeka Belajar?

Rencana Tindak Lanjut (RTL)

Webinar RumBel #1