Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Latihanunit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, mysql50conn, mysql55conn, sqldb, db, FileUtil, Forms,
- Controls, Graphics, Dialogs, StdCtrls, DBGrids;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Datasource1: TDatasource;
- DBGrid1: TDBGrid;
- Edit1: TEdit;
- Label1: TLabel;
- MySQL55Connection1: TMySQL55Connection;
- SQLQuery1: TSQLQuery;
- SQLTransaction1: TSQLTransaction;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- MySQL55Connection1.DatabaseName:='sdm';
- MySQL55Connection1.UserName:='root';
- MySQL55Connection1.Password:='kucing';
- MySQL55Connection1.Transaction:=SQLTransaction1;
- SQLTransaction1.DataBase:=MySQL55Connection1;
- SQLQuery1.DataBase:=MySQL55Connection1;
- SQLQuery1.Transaction:=SQLTransaction1;
- SQLQuery1.UsePrimaryKeyAsKey:=false;
- SQLQuery1.sql.text:='SELECT * FROM pegawai';
- Datasource1.DataSet:=SQLQuery1;
- DBGrid1.DataSource:=Datasource1;
- MySQL55Connection1.Open;
- if MySQL55Connection1.Connected then
- begin
- Label1.Caption:='Database sudah berhasil terhubung';
- SQLQuery1.Open;
- end;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- SQLQuery1.Close;
- SQLQuery1.sql.Text:=edit1.Text;
- SQLQuery1.open;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- MySQL55Connection1.Close;
- MySQL55Connection1.Free;
- close;
- end;
- end.
Add Comment
Please, Sign In to add comment