Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Latihan2unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, mysql55conn, FileUtil, Forms, Controls, Graphics, Dialogs,
- StdCtrls, EditBtn;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- DateEdit1: TDateEdit;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- MySQL55Connection1: TMySQL55Connection;
- procedure Button1Click(Sender: TObject);
- procedure DateEdit1Change(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Label2Click(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.Label2Click(Sender: TObject);
- begin
- end;
- procedure TForm1.DateEdit1Change(Sender: TObject);
- begin
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- // perintah untuk menutup form & memutuskan koneksi ke server
- MySQL55Connection1.Close;
- MySQL55Connection1.Free;
- close;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- // Mengkoneksikan form ke database MySQL pada saat form di load
- // Sehingga Label paling atas akan menampilkan status terkoneksi
- // Isikan data untuk login ke server
- MySQL55Connection1.DatabaseName:='pdam';
- MySQL55Connection1.UserName:='root';
- MySQL55Connection1.Password:='kucing';
- // Buka koneksi ke server
- MySQL55Connection1.Open;
- if MySQL55Connection1.Connected then
- begin
- // Kalau terkoneksi tampilkan pesan ini di label
- Label1.Caption:='Terkoneksi ke MySQL';
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement