Hello, Im a beginner and i need help with my problem.
How to create insert/save/update/delete and clear Fields(DBEdit) buttons for mysql database using delphi.
This is my example.
First I create mysql database:
create database Contacts;
create table coktacts(
id int auto_increment primary key not null,
First_name varchar(25) not null,
Last_name varchar(25) not null,
Address varchar(50) not null,
Country varchar(25) not null,
Phone varchar(13));
Then I create application in delphi.
File -> New -> VLC Forms Application
In Forms I Use:
DBGrid
5 buttons (insert/save/Update/delete/clear)
AdoConnection
AdoDataset
Data Source
then set my AdoConnection:
- ConnectionString: Find my source to connection ...
- LoginPrompt: false
- Connected: True
- Name: AdoConnection1
Then set AdoDataSet:
Connection: AdoConnection1
Name: AdoDataSet1
CommandType: cmdTable
CommandText: Contacts
for dataset I use Field Editor-add fields-Drag and Drop to Form.
Then set DAtaSource:
DataSet: AdoDataSet1
Name: DataSource1
Then set DBGrid:
DataSource: DataSource1
ColumnsTDBGridColumns): id, First Name, Last Name, Address, Country, Phone.
For Show my database into DBgrid I use Code:
for procedure TForm3.FormCreate(Sender: TObject);
begin
ADODataSet1.Active := true;
end;
Question 1: how to create insert/save/update/delete/clear buttons?
I dont want to use DBnavigator.
When I click INSERT button I want to clear DBEdits fiels(Firstname,lastname,address ...) input new contact info and SAVE to my database.
How to create insert/save/update/delete and clear Fields(DBEdit) buttons for mysql database using delphi.
This is my example.
First I create mysql database:
create database Contacts;
create table coktacts(
id int auto_increment primary key not null,
First_name varchar(25) not null,
Last_name varchar(25) not null,
Address varchar(50) not null,
Country varchar(25) not null,
Phone varchar(13));
Then I create application in delphi.
File -> New -> VLC Forms Application
In Forms I Use:
DBGrid
5 buttons (insert/save/Update/delete/clear)
AdoConnection
AdoDataset
Data Source
then set my AdoConnection:
- ConnectionString: Find my source to connection ...
- LoginPrompt: false
- Connected: True
- Name: AdoConnection1
Then set AdoDataSet:
Connection: AdoConnection1
Name: AdoDataSet1
CommandType: cmdTable
CommandText: Contacts
for dataset I use Field Editor-add fields-Drag and Drop to Form.
Then set DAtaSource:
DataSet: AdoDataSet1
Name: DataSource1
Then set DBGrid:
DataSource: DataSource1
ColumnsTDBGridColumns): id, First Name, Last Name, Address, Country, Phone.
For Show my database into DBgrid I use Code:
for procedure TForm3.FormCreate(Sender: TObject);
begin
ADODataSet1.Active := true;
end;
Question 1: how to create insert/save/update/delete/clear buttons?
I dont want to use DBnavigator.
When I click INSERT button I want to clear DBEdits fiels(Firstname,lastname,address ...) input new contact info and SAVE to my database.