Delphi tutorial MS Access database with KADao
This is Delphi Tutorial about creating and manipulating MS Access database
with KADAo component ( http://www.kadao.dir.bg/ ) ,
and as usual you can find here source code for this app,
and also exe files at address : https://drive.google.com/open?id=0B_njK7HczCjDWkdtbTVseExyYW8
Here is the video :
Source code for this app example :
unit MainForm
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, KDaoTable, KDaoDataBase, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
lbTblName: TLabel;
Label2: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Label5: TLabel;
Edit3: TEdit;
Button5: TButton;
Button6: TButton;
Database1: TKADaoDatabase;
Table1: TKADaoTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button7: TButton;
lbDbName: TLabel;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
SaveDialog1.InitialDir:=ExtractFilePath(Application.ExeName) ;
if SaveDialog1.Execute() then
begin
Database1.Close;
Database1.CreateAccessDatabase(SaveDialog1.FileName+'.mdb');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
TM:TKADaoTableManager;
begin
if Database1.Connected=False then Exit;
try
Database1.Connected:=true;
TM:=TKADaoTableManager.Create(Database1);
TM.TableName:=InputBox('Insert table name','Table name','Table 1');
TM.FieldDefs.Add('Field 1',ftInteger,0,False);
TM.FieldDefs.Add('Field 2',ftString,100,False);
TM.FieldDefs.Add('Field 3',ftDate,0,False);
TM.IndexDefs.Add('Field 1','Field 1',[ixPrimary,ixUnique]);
TM.IndexDefs.Add('Field 2','Field 2',[]);
TM.CreateTable;
lbTblName.Caption:=TM.TableName;
TM.Free;
Database1.Connected:=False;
Database1.Open;
ComboBox1.Items.Clear;
ComboBox1.Items.AddStrings(Database1.TableNames);
ComboBox1.ItemIndex:=0;
except
ShowMessage('Error creating table');
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if OpenDialog1.Execute() then
begin
OpenDialog1.InitialDir:=ExtractFilePath(Application.ExeName);
Database1.Close;
Database1.Database:=OpenDialog1.FileName;
Database1.Open;
lbDbName.Caption:=Database1.Database;
ComboBox1.Items.Clear;
ComboBox1.Items.AddStrings(Database1.TableNames);
ComboBox1.ItemIndex:=0;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if (Database1.Connected=True) and ( ComboBox1.Text<>'') then
begin
Table1.Close;
Table1.TableName:=ComboBox1.Text;
Table1.Open;
DBGrid1.Columns[0].Width:=100;
DBGrid1.Columns[1].Width:=200;
DBGrid1.Columns[2].Width:=100;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if (Edit1.Text<>'') then begin
Table1.Insert;
Table1.Append;
Table1.FieldByName('Field 1').AsInteger:=StrToInt(Edit1.Text);
Table1.FieldByName('Field 2').AsString:=Edit2.Text;
Table1.FieldByName('Field 3').AsDateTime:=StrToDate(Edit3.Text);
Table1.Post;
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Table1.Edit;
Table1.UpdateRecord;
Table1.Post;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Table1.Delete;
end;
end.
Tutorials by KobyX
Login
Enter your username and password to enter your Blogger Dasboard
Featured Post
Power resistor DIY
Power resistor DIY This is one simple way to create power resistor at home. I needed 0,33 ohm resistor with some larger wattage so I de...
Recent Articles
-
Delphi tutorial – connect MySQL with ZEOS library After you manage to create this application, you will actually have small MySQ...
-
For this app to create you will need "sqlite3.dll" file which you can download from : https://sqlite.org/ or you can download ...
-
Delphi Tutorial work with INI files In this lesson you can learn how to work with INI files in Delphi. You can learn how to...
-
Delphi Tutorial Listview In this tutorial you can learn how to work with Listview in Delphi. You can learn how to create,edit and delete ...
-
Delphi tutorial MS Access database with KADao This is Delphi Tutorial about creating and manipulating MS Access database with KADAo com...
-
In this example I will show you how to use external fonts in your application, without installing font. Following video shows details about...
-
Power resistor DIY This is one simple way to create power resistor at home. I needed 0,33 ohm resistor with some larger wattage so I de...
-
In this video you can learn how to work with Timer in Delphi. You can learn how to manipulate with components using timer. example applic...
-
Delphi Tutorial Listbox manipulate items In this video you can learn how to manipulate with Listbox items in Delphi. You can learn how ...
-
Delphi tutorial Client server application This is Delphi Tutorial about client-server application, and as usual you can find here sourc...
Saturday, September 24, 2016
Delphi tutorial MS Access database with KADao
Comments
Search This Blog
Popular Posts
-
Delphi tutorial – connect MySQL with ZEOS library After you manage to create this application, you will actually have small MySQ...
-
For this app to create you will need "sqlite3.dll" file which you can download from : https://sqlite.org/ or you can download ...
-
Delphi Tutorial work with INI files In this lesson you can learn how to work with INI files in Delphi. You can learn how to...
-
Delphi Tutorial Listview In this tutorial you can learn how to work with Listview in Delphi. You can learn how to create,edit and delete ...
-
Delphi tutorial MS Access database with KADao This is Delphi Tutorial about creating and manipulating MS Access database with KADAo com...
-
In this example I will show you how to use external fonts in your application, without installing font. Following video shows details about...
-
Power resistor DIY This is one simple way to create power resistor at home. I needed 0,33 ohm resistor with some larger wattage so I de...
-
In this video you can learn how to work with Timer in Delphi. You can learn how to manipulate with components using timer. example applic...
-
Delphi Tutorial Listbox manipulate items In this video you can learn how to manipulate with Listbox items in Delphi. You can learn how ...
-
Delphi tutorial Client server application This is Delphi Tutorial about client-server application, and as usual you can find here sourc...
0 comments: