home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programming Unleashed
/
Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso
/
chap21
/
insert2
/
main.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-20
|
1KB
|
65 lines
unit Main;
{ Program copyright (c) 1994 by Charles Calvert }
{ Project Name: INSERT2 }
{ After you do an insert, the call to Refresh won't
work unless you set RequestLive to True }
interface
uses
WinTypes, WinProcs, Classes,
Graphics, Forms, Controls,
DB, DBGrids, DBTables,
StdCtrls, Grids;
type
TForm1 = class(TForm)
Query1: TQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Insert: TButton;
Query2: TQuery;
Delete: TButton;
Query3: TQuery;
procedure InsertClick(Sender: TObject);
procedure DeleteClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
Dialogs;
{$R *.DFM}
procedure TForm1.InsertClick(Sender: TObject);
begin
Query2.Prepare;
Query2.Params[0].AsString := 'Erehwon';
Query2.Params[1].AsString := 'None';
Query2.Params[2].AsString := 'Imagination';
Query2.Params[3].AsFloat := 0.0;
Query2.Params[4].AsFloat := 1.0;
Query2.ExecSQL;
Query1.Refresh;
end;
procedure TForm1.DeleteClick(Sender: TObject);
begin
if MessageDlg('Delete?', mtConfirmation, [mbYes,mbNo], 0) <> idYes then Exit;
Query3.Prepare;
Query3.Params[0].AsString := Query1.Fields[0].AsString;
Query3.ExecSQL;
Query1.Refresh;
end;
end.