Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

News Tips .NET Software VCL Software Partners  

Insert/Update/Delete using by SQL
This example uses COUNTRY.DB database of DBDEMOS standard alias. SQL is a power tool for working with database. This example shows 3 main operations with database (Insert, Update and Delete record).

// Insert record
procedure TForm1.Button1Click(Sender: TObject);
begin
  with Query1 do
  begin
    Active:=False;
    SQL.Clear;
    SQL.Add('Insert into country(NAME,CAPITAL,CONTINENT,AREA,POPULATION) 
               values(
                 ''A_My_Country'', 
                 ''A_My_Capital'', 
                 ''A_My_Continent'', 
                 1, 
                 1)');
    ExecSQL;
  end;
  Table1.Refresh;
end;

// Delete record
procedure TForm1.Button2Click(Sender: TObject);
begin
  with Query1 do
  begin
    Active:=False;
    SQL.Clear;
    SQL.Add('Delete from country where name=''A_My_Country''');
    ExecSQL;
  end;
  Table1.Refresh;
end;

//Update record
procedure TForm1.Button3Click(Sender: TObject);
begin
  with Query1 do
  begin
    Active:=False;
    SQL.Clear;
    SQL.Add('Update country set name=''A_Your_Country'' 
               where name=''A_My_Country''');
    ExecSQL;
  end;
  Table1.Refresh;
end;

Related topics
Using SQL query
Insert/Edit/Delete methods

For more
Delphi Help

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software