Show specific SQL data lazarus / 16-Databases ---------------------------------------------------------------------- ironman139 · 2016-10-25 04:38 Hello, I have a question again. I wont to filter a specific row from a sql database and want to show them in a listbox. When i use this code, i get the whole row displayed in the Listbox. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm3.Button1Click(Sender: TObject);  begin     SQLQuery1.Close;     SQLQuery1.SQL.text:='SELECT * FROM Auftrag ';        while (SQLQuery1.Eof = false) do          begin         Listbox1.Items.add(SQLQuery1.Fields[1].AsString);          SQLQuery1.Next;           end;end; But when i apply my filter function, I just get the first record from the table. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm3.Button1Click(Sender: TObject);  begin     SQLQuery1.Close;     SQLQuery1.SQL.text:='SELECT * FROM Auftrag where Fertig = :Fertig';      SQLQuery1.Params.ParamByName('Fertig').AsString := Edit1.Text;     SQLQuery1.Open;        while (SQLQuery1.Eof = false) do          begin         Listbox1.Items.add(SQLQuery1.Fields[1].AsString);        SQLQuery1.Next;           end; end; ---------------------------------------------------------------------- mangakissa · 2016-10-25 07:00 What do you want to accomplish? Code 1 and 2 gives the record you asked. Code 2 is filtered by parameter. If there's only one record with your put text, it's a logical one. I don't know your data in your table. You have to tell more. TIP: if you only want to fill you listbox, don't use '*' in your query, bu only the fields you want to see. ---------------------------------------------------------------------- ironman139 · 2016-10-25 12:41 Its basically a shedule sofware. My table looks like : Person               Date Person1             10.24.2016 Person2             11.28.2016 Person3             11.28.2016 Person4             12.29.2016 ... So I type in now the date in my Edit1 field. But i just get 1 record out of the table. But I want all with the specific date. ---------------------------------------------------------------------- balazsszekely · 2016-10-25 12:46 Hi ironman139, After the line SQLQuery1.Open insert SQLQuery1.First; Date is string on your db? ---------------------------------------------------------------------- ironman139 · 2016-10-25 13:39 Yes , the date is saved as a string in the sql Edit: Sql.query1.first give me just the first record again. But I want to type in the date in the edit1. Or pick it by the datetimepicker and search all records with the same data ---------------------------------------------------------------------- valdir.marcos · 2016-10-25 15:01 If Fertig and Edit1.Text are both string, are they compared with the same format? For example: Fertig = '25/10/2016' and Edit1.Text = '25/10/2016'. ---------------------------------------------------------------------- ironman139 · 2016-10-25 15:16 Yes It's exactly the same format While saving i put the date by the datetimepicker in the sql and for displaying also by the datetimpicker to the edit ---------------------------------------------------------------------- LacaK · 2016-10-25 16:58 Then this must return all record where Fertig=text in your edit field Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin     SQLQuery1.Close;     SQLQuery1.SQL.text:='SELECT * FROM Auftrag where Fertig = :Fertig';     SQLQuery1.ParamByName('Fertig').AsString := Edit1.Text;     SQLQuery1.Open;        Listbox1.Items.Clear;       while not SQLQuery1.Eof do          begin          Listbox1.Items.add(SQLQuery1.Fields[1].AsString);          SQLQuery1.Next;          end;end; ---------------------------------------------------------------------- ironman139 · 2016-10-25 18:31 Hm I'll post the whole code tonight when I'm at home. I have no idea at the moment . ---------------------------------------------------------------------- ironman139 · 2016-10-26 04:25 I´m just stupid, sorry I have 3 different stuffs in my table Person Fertig Erstellt   ( German Words  ) So fertig means finished and erstellt means created, and I changed both , and one has no dates inside... sorry for that  It´s working perfect now. ---------------------------------------------------------------------- Omirbay · 2016-10-26 12:40 Hello there! I m encounterin some difficulty to reply by mobile. I follow what you want, n succeeded in doin so when I was having the same problem.  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure search(str : string);Var Ssql : string;Begin With form1 or datamodule do begin  //with here you need to specify the form or datamodule query component is placed  Query.close;  Query.sql.clear;  Queru.sql.add('SELECT * FROM AUTFRAG');  Query.sql.add('WHERE fertig like ' + quotedstr(str));  Query.open; End;  End; Procedure edit1.onchange;Begin Search(edit1.text);End; ---------------------------------------------------------------------- Omirbay · 2016-10-26 12:47 Oops I forgot to include listbox Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure search(str:string);Var S1 : string; I,n : integer;Begin With form1 or datamodule do begin  //with here you need to specify the form or datamodule query component is placed  Query.close;  Query.sql.clear;  Queru.sql.add('SELECT * FROM AUTFRAG');  Query.sql.add('WHERE fertig like ' + quotedstr(str));  Query.open; End;  N := query.recordcount-1; Listbox1.Items.clear; Query.first; For I := 0 to n do begin   S1 := query.fieldbyname('fertig').asstring;    Listbox1.items.add(s1);   Query.next; End;End; ---------------------------------------------------------------------- ironman139 · 2016-10-27 01:56 Another question, how can i show the last record of a colum ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT LAST(column_name) FROM table_name; This one is not working unfortunately ... ---------------------------------------------------------------------- mangakissa · 2016-10-27 06:37 http://www.w3schools.com/sql/sql_func_last.asp or use property last of dataset. ---------------------------------------------------------------------- ironman139 · 2016-10-27 12:38 I figured out when I just put Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SQLQuery1.Last;After the .Open syntax, I get the last one. Easy