Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Find is not finding the record
Mon, Jul 8 2019 11:07 PMPermanent Link

KimHJ

Comca Systems, Inc

This is driving me crazy for hours I can not get Find to work. I have used it before many times, but always with Strings.

Using the latest version of EWB and EDB

I have a table with Employee. The first column is EmployeeID integer. The Constraint is set to this field and there is no other Indexes.

This is the query in the Dataset dropped on the Database form.

Select * from employee
where EmployeeID={EmployeeID=1}

Base table is employee.

There is two records in the table with EmployeeID 100 and 101

Here is my code to find the employee, the DataSet's name is FindEmp.

.if FindEmployee(StrToInt(EmpIdEd.Text)) then
  begin
           Label.Caption := FindEmp.Columns['EmpName'].AsString;
           FindEmp.Close;
  end;

function TDatabase1.FindEmployee(EmpID: Integer): Boolean;
begin
with FindEmp do
         begin
               Open;
               try
                   InitFind;
                   Columns['EmployeeID'].AsInteger:=EmpID;
                   if Find(False,False) then
                       Result:=True
                   else
                       Result:=False;

               finally
        
               end;
end;

It always return False.

Thanks for any help.
Kim
Mon, Jul 8 2019 11:55 PMPermanent Link

KimHJ

Comca Systems, Inc

I found that if I drop the employee table without a query and do a LoadRows(Employee) before using Find it works, so there must be something I'm missing in the Query DataSet.

Kim
Image