SHARE
TWEET

Source Code Free Pascal dengan Tombol Close

stevennathaniel Dec 13th, 2013 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unit Latihanunit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, mysql50conn, mysql55conn, sqldb, db, FileUtil, Forms,
  9.   Controls, Graphics, Dialogs, StdCtrls, DBGrids;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Button2: TButton;
  18.     Button3: TButton;
  19.     Datasource1: TDatasource;
  20.     DBGrid1: TDBGrid;
  21.     Edit1: TEdit;
  22.     Label1: TLabel;
  23.     MySQL55Connection1: TMySQL55Connection;
  24.     SQLQuery1: TSQLQuery;
  25.     SQLTransaction1: TSQLTransaction;
  26.     procedure Button1Click(Sender: TObject);
  27.     procedure Button2Click(Sender: TObject);
  28.     procedure Button3Click(Sender: TObject);
  29.   private
  30.     { private declarations }
  31.   public
  32.     { public declarations }
  33.   end;
  34.  
  35. var
  36.   Form1: TForm1;
  37.  
  38. implementation
  39.  
  40. {$R *.lfm}
  41.  
  42. { TForm1 }
  43.  
  44. procedure TForm1.Button1Click(Sender: TObject);
  45. begin
  46.  
  47.   MySQL55Connection1.DatabaseName:='sdm';
  48.   MySQL55Connection1.UserName:='root';
  49.   MySQL55Connection1.Password:='kucing';
  50.   MySQL55Connection1.Transaction:=SQLTransaction1;
  51.  
  52.   SQLTransaction1.DataBase:=MySQL55Connection1;
  53.  
  54.   SQLQuery1.DataBase:=MySQL55Connection1;
  55.   SQLQuery1.Transaction:=SQLTransaction1;
  56.   SQLQuery1.UsePrimaryKeyAsKey:=false;
  57.   SQLQuery1.sql.text:='SELECT * FROM pegawai';
  58.  
  59.   Datasource1.DataSet:=SQLQuery1;
  60.   DBGrid1.DataSource:=Datasource1;
  61.  
  62.   MySQL55Connection1.Open;
  63.   if MySQL55Connection1.Connected then
  64.   begin
  65.  
  66.     Label1.Caption:='Database sudah berhasil terhubung';
  67.  
  68.     SQLQuery1.Open;
  69.  
  70.   end;
  71.  
  72.  
  73.   end;
  74.  
  75. procedure TForm1.Button2Click(Sender: TObject);
  76. begin
  77.  
  78.  
  79.   SQLQuery1.Close;
  80.   SQLQuery1.sql.Text:=edit1.Text;
  81.   SQLQuery1.open;
  82. end;
  83.  
  84. procedure TForm1.Button3Click(Sender: TObject);
  85. begin
  86.  
  87.   MySQL55Connection1.Close;
  88.   MySQL55Connection1.Free;
  89.   close;
  90.  
  91. end;
  92.  
  93.  
  94.  
  95. end.
RAW Paste Data
Pastebin PRO Summer Special!
Get 60% OFF on Pastebin PRO accounts!
Top