BY : MISBAHUL MUNIR
I. Membuat Database Mysql dengan server localhost di xampp
1. Membuat database baru dengan nama dbmtkul
2. Tekan tombol create untuk menyimpannya
3. membuat tabel dengan nama tb_mhs
4. tekan tombol Go untuk menyimpannya
5. selanjutnya mengisi nama-nama field
6. tekan tombol save untuk menyimpanya
II. Mengkoneksikan Database Mysql ke dalam Delphi menggunakan Data Source (ODBC)
1. Buka Adminirative tool ikon di Control Panel
2. Double klik di Data Sources (ODBC) icon di dalamnya
3. Pilih tab system DNS, Klik di Add di tab System DNS
4. Pilih Mysql ODBC 5.1 Driver, Klik finish
III. Implementasi Program
1. Design form
2. Design properties
Object Inspector Properties Keterangan
Form1 Name Form1
Caption Form1
Panel1 Name Panel1
Label1 Name INPUT MATA KULIAH
Label2 Name NIM
Label3 Name NAMA
Label4 Name MATA KULIAH
Label5 Name KELAS
Label6 Name HARI
Label7 Name JAM
Edit1 Name Edit1
Text -
Edit2 Name Edit2
Text -
Combobox1 Name Combobox1
Text -
items Bahasa Inggris
Delphi
Matematika Diskrit
Maintenance
Sistem Digital
Statistika
Edit3 Name Edit3
Text -
Edit4 Name Edit4
Text -
Edit5 Name Edit5
Text -
Button1 Name Button1
Caption SIMPAN
Button2 Name Button2
Caption EDIT
Button3 Name Button3
Caption BATAL
Button4 Name Button4
Caption HAPUS
Button5 Name Button5
Caption KELUAR
ADOConnection1 Name ADOConnection1
ConnectionString Alamat database ( dbmtkul )
LoginPrompt False
ADOTable1 Name ADOTable1
Connection ADOConnection1
TableName Nama tabel ( tb_mhs )
Active True
DataSource1 DataSet1 ADOTable1
DBGrid1 DataSource1 DataSource1
Ket:
Edit, Label, RadioButton1 dan Button Ada Di Pallete Standart
ADO Connection Ada Di Pallete ADO
ADOTable Ada di Pallete ADO
DataSource Ada di Pallete Data Acces
DBGrid Ada di Pallete Data Control
3. Mensetting ADO Connection
a. Setting ADOConnection, pastikan ADOConnection aktif (dalam keadaan di Click)
b. Pada properties click ConnectionString sehingga muncul tampilan sebagai berikut
c. Pilih Use Connection String dan Click Build
d. Double Click atau Click Next pada Microsoft OLE DB Provider for ODBC Drivers
e. Pilih Use data source name untuk memilih Database (dbmtkul.sql)
f. Test koneksi dengna mengklik Test Connection, jika muncul konfirmasi seperti gambar dibawah ini berarti koneksi berhasil
IV. Listing Kode Program
1. Listing Kode Combobox1
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
case ComboBox1.ItemIndex of
0: begin
Edit3.Text:='F-Lt2.R2';
Edit4.Text:='Kamis';
Edit5.Text:='09.30-11.00';
end;
1: begin
Edit3.Text:='H-Lab2';
Edit4.Text:='Selasa';
Edit5.Text:='14.30-16.45';
end;
2: begin
Edit3.Text:='F-Lt2.R1';
Edit4.Text:='Selasa';
Edit5.Text:='08.00-11.00';
end;
3: begin
Edit3.Text:='E-Lt1.R5';
Edit4.Text:='Senin';
Edit5.Text:='08.00-10.15';
end;
4: begin
Edit3.Text:='F-Lt1.R2';
Edit4.Text:='Minggu';
Edit5.Text:='10.15-12.00';
end;
6: begin
Edit3.Text:='E-Lt1.R5';
Edit4.Text:='Kamis';
Edit5.Text:='09.30-11.00';
end;
end;
2. Listing Kode Simpan
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOTable1.Append;
ADOTable1['nim']:=Edit1.Text;
ADOTable1['nama']:=Edit2.Text;
ADOTable1['mata_kuliah']:=ComboBox1.Text;
ADOTable1['kelas']:=Edit3.Text;
ADOTable1['hari']:=Edit4.Text;
ADOTable1['jam']:=Edit5.Text;
Edit1.Clear;
Edit2.Clear;
ComboBox1.Text:='';
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit1.SetFocus;
end;
3. Listing Kode Edit
procedure TForm1.Button2Click(Sender: TObject);
begin
ADOTable1.Edit;
ADOTable1['nim']:=Edit1.Text;
ADOTable1['nama']:=Edit2.Text;
ADOTable1['mata_kuliah']:=ComboBox1.Text;
ADOTable1['kelas']:=Edit3.Text;
ADOTable1['hari']:=Edit4.Text;
ADOTable1['jam']:=Edit5.Text;
Edit1.Clear;
Edit2.Clear;
ComboBox1.Text:='';
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit1.SetFocus;
end;
4. Listing Kode Batal
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
ComboBox1.Text:='';
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit1.SetFocus;
ADOConnection1.Connected:=True;
ADOTable1.Active:=False;
ADOTable1.Active:=True;
end;
5. Listing Kode Hapus
procedure TForm1.Button4Click(Sender: TObject);
begin
ADOTable1.Delete;
Edit1.Clear;
Edit2.Clear;
ComboBox1.Text:='';
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
Edit1.SetFocus;
ADOConnection1.Connected:=True;
ADOTable1.Active:=False;
ADOTable1.Active:=True;
end;
6. Listing Kode Keluar
procedure TForm1.Button5Click(Sender: TObject);
begin
Application.Terminate;
end;
V. Hasil Aplikasi ketika dijalankan
GOOD LUCK