Hello lhimes,
Examples bellow are based on :
- a table called clients and a table called gender
- two fields : name, surname in table clients
- one field : id_gender in table gender
If you want to save values from edit fields and comboboxes, you have to assign their content to a variable which must first be declared
procedure Form2_Button1_OnClick (Sender: string; var Cancel: boolean);
var
gender_id,client_name, client_surname : String;
begin
gender_id := IntToStr(Form2.ComboBox1.dbItemID);
client_name := Form2.Edit1.Text;
client_surname := Form2.Edit2.Text;
SQLExecute('INSERT INTO clients(id_gender,name,surname) VALUES("'+gender_id+'","'+client_name+'","'+client_surname+'")');
end;
The syntax for performing and update needs some specific elements :
what fields do you want to update ?
in what table ?
under which condition ?
procedure Form2_Button1_OnClick (Sender: string; var Cancel: boolean);
var
gender_id,client_name, client_surname : String;
begin
gender_id := IntToStr(Form2.ComboBox1.dbItemID);
client_name := Form2.Edit1.Text;
client_surname := Form2.Edit2.Text;
SQLExecute('UPDATE clients SET id_gender="'+gender_id+'",name = "'+client_name+'" WHERE surname="'+client_surname+'" ');
end;
In this (silly) example, you are going to change the value of name and gender where the value of surname matches something you selected.
Do you know that MVD can do all that for you without a single line of code ?
Hope this helps
Mathias
I'm a very good housekeeper !
Each time I get a divorce, I keep the house
Zaza Gabor