1 (edited by dbk 2018-11-11 21:37:32)

Topic: [SOLVED] SQL select from where id = id on the form

Hello friends,

i am trying to make a dataset with a SQL query to get all rows from a table where the id should match the ID that is entered on the form (textbox name: Edit10).

Is it possible to take the value of textbox in the query? If not how should i approach this?

Many thanks in advance!

SQLQuery('SELECT * FROM table WHERE table.field_id = ??? ', Results1);

2 (edited by sibprogsistem 2018-11-11 19:20:04)

Re: [SOLVED] SQL select from where id = id on the form

procedure Form1_ComboBox1_OnChange (Sender: TObject);
begin
   form1.Memo1.Text:=SQLExecute('SELECT nn FROM tt WHERE id = ' +form1.ComboBox1.sqlValue);
end;

procedure Form1_Edit2_OnChange (Sender: TObject);
begin
   form1.Memo1.Text:=SQLExecute('SELECT nn FROM tt WHERE id = ' +form1.Edit2.Text);
end;
Post's attachments

Attachment icon ww.rar 4 kb, 824 downloads since 2018-11-11 

Re: [SOLVED] SQL select from where id = id on the form

sibprogsistem wrote:
procedure Form1_ComboBox1_OnChange (Sender: TObject);
begin
   form1.Memo1.Text:=SQLExecute('SELECT nn FROM tt WHERE id = ' +form1.ComboBox1.sqlValue);
end;

procedure Form1_Edit2_OnChange (Sender: TObject);
begin
   form1.Memo1.Text:=SQLExecute('SELECT nn FROM tt WHERE id = ' +form1.Edit2.Text);
end;

Thank you sibprogsistem! It works!