Delphi program suddenly won't post query changes
I have Delphi application that has been in production for several years now and recently a specific piece of code has stopped working. In the OnClose
event for the form I have the following:
procedure TfrmPublicEmpInfo.FormClose(Sender: TObject;var Action: TCloseAction);
var
i : integer;
strWorkDays : string;
begin
If cbMonday.Checked then strWorkDays := strWorkDays + 'Mo';
If cbTuesday.Checked then strWorkdays := strWorkDays + 'Tu';
If cbWednesday.Checked then strWorkdays := strWorkDays + 'We';
If cbThursday.Checked then strWorkdays := strWorkDays + 'Th';
If cbFriday.Checked then strWorkdays := strWorkDays + 'Fr';
If 开发者_运维知识库cbSaturday.Checked then strWorkdays := strWorkDays + 'Sa';
If cbSunday.Checked then strWorkdays := strWorkDays + 'Su';
if strWorkDays <> '' then
begin
qryPubEmployees.Edit;
qryPubEmployees.FieldValues['OCCUPATION'] := strWorkDays;
end;
dtpPEEndTimeChange(self);
dtpPEStartTimeChange(self);
For i := 0 to ComponentCount - 1 do
begin
If Components[i] is TQuery Then
with Components[i] as TQuery do
begin
if State = dsEdit then
post;
end;
end;
end;
It gets to the dtpPEEndTimeChange(self)
call which is this:
procedure TfrmPublicEmpInfo.dtpPEEndTimeChange(Sender: TObject);
begin
qryPubEmployees.Edit;
dbePEEndTime.Field.Value := StrToInt(FormatDateTime('HHMM', dtpPEEndTime.Time));
end;
while in this function the program calls Windows.pas and gets stuck in:
function GetTickCount; external kernel32 name 'GetTickCount';
it never posts the changes to the record.
Does anyone know if any Windows updates may have caused this malfunction? We are currently on Windows XP Professional Version 5.1 SP 3.
GetTickCount returns Cardinal. If you are storing result to integer variable, it will result to integer overflow when your computer has been up for 25 days or so. I'm just guessing, but that once was problem in our application.
精彩评论