Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing details entered from a text field into a database table...

Status
Not open for further replies.

nikeloeleven

Programmer
Feb 15, 2005
32
0
0
GB
Hi there, I have a database called IPM.gdb.... It is made in Interbase so i used Interbase controls to connect the database to delphi...one of the Tables is called "StaffMember"
It has 4 fields: StaffID
Forename
Surname
StaffGroup
Form

I have a form (called formAddNewStaffMember) that ive created to allow users to add new staff memebers....

what i want to do is store the values entered into the text fields into the "StaffMember" table....

i will be using a button to save the details so i want to add code in the "OnClick" event....

On the click of the button... the details in the text boxes should be saved into the "StaffMember" table as a new record...

Please help me on this one... thank you everyone:)
 
Create a database connection, then throw a TQuery or similar on the form, paste this code:

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  with Query1 do
  begin
    SQL.Add('INSERT INTO StaffMember (StaffID,Forename,Surname,StaffGroup,Form) VALUES (:StaffId,:Forename,:Surname,:StaffGroup,:Form)');
    ParamByName('StaffId').AsInteger := StrToInt(EditID.text);
    ParamByName('Forename').AsInteger := EditForename.Text;
    ParamByName('Surname').AsInteger := EditSurname.Text;
    ParamByName('StaffGroup').AsInteger := EditStaffGroup.Text;
    ParamByName('Form').AsInteger := EditForm.Text;
    ExecSQL;
  end;
end;



...Ok then, it's not that easy... You have to add som TEdit's too... :)


KungTure-RX.jpg

//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top