View Single Post
Old Aug 19th, 2005, 6:16 AM   #17
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Ok now I think this needs to be moved to the delphi forum.

I have this code

procedure Tfrm_clock_In.btn_enterClick(Sender: TObject);
var
          Today:TDateTime;
          Executed:boolean;
begin
Executed:= false;
Today:= Date;
tbl_employees.Open;
tbl_employees.First;
Repeat
        if strtoint(Edit_Employee_ID.text) = tbl_employeesEmployee_ID.value then
           begin
                tbl_shift.Open;
                tbl_shift.Last;
                repeat
                        if (strtoint(Edit_Employee_ID.text) = tbl_shiftEmployee_ID.value) and (tbl_shiftDate_.Value = Today) then
                           begin
                                if Datetostr(tbl_shiftTime_Out.value)='' then
                                        begin
                                                //sql to updae file with clock out time
                                                Executed:=true;
                                                showmessage('Clocked Out')
                                        end;
                           end
                        else tbl_shift.Prior;
                Until (Executed=true) or (tbl_shift.Bof); //until record update or no shift found
           end
        else tbl_employees.Next;
Until (Executed=true) or (tbl_employees.Eof);

if tbl_employees.Eof then showmessage('Invalid User ID'); //if don't find a matching employee number then invalid

If tbl_shift.Bof then //if don't find a record to update then create new one
        begin
                //sql to create a new record
        end;
        
end;

And for some reason it freezes the program and i have to reset it. I'm thinking its going to be one of those repeats that's freezing it. Can anyone see my error?

Also I couldn't use DATETIME in sql because i don't have sql server 2005.

Hmm...and i'm not sure what one is but i've heard about memory leaks, and after a while it tells me there is not sufficient memory to run the program, am i leaking memory?

Last edited by gj15987; Aug 19th, 2005 at 6:30 AM.
gj15987 is offline   Reply With Quote