在表中更新字段时访问违规

时间:2015-08-18 10:53:51

标签: delphi delphi-6

我已经创建了一个exe(Update.exe)文件来通过SQL语句更新表中的记录 我已经创建了另一个程序(update_service.exe),它在windows中作为管理服务运行。

当我运行update.exe standalone时,它会更新表中的记录。没有错误。它有效。
当update.exe通过update_service.exe执行时,它会给我一个访问冲突:

Access violation at address 40006A2F in module 'rtl60.bpl'. Read of address 00000004.

发生错误的操作系统是W2003服务器 Delphi versie 6
数据访问组件:ADODB
它是一个VCL应用程序

在我当地的W7电脑上一切正常。

代码:

procedure TService1.tmr1Timer(Sender: TObject);
var
  LclParams : string;
begin
  if (FBusyUpgrading) or (UpgradeFileExists()) then
    Exit;

  if HourOfTheDay(Time) = HourOfTheDay(strToTime(FStartServiceTime)) then
    if MinuteOfTheHour(Time) = MinuteOfTheHour(strToTime(FStartServiceTime)) then
      begin
          FBusyUpgrading := True;
          WinExecAndWait32(IncludeTrailingBackslash(GetCurrentDir) + 'update.exe /START', SW_NORMAL);
          FBusyUpgrading := False
      end;

end;

我该如何解决这个问题?

FWIW:更新的SQL语句:

sl.Add('UPDATE Licentie SET ExpiratieDatum=' + QuotedStr(LicenseKey.Expiratie) + ' WHERE Active=True')

(LicenseKey.Expiratie是一个普通的字符串)

1 个答案:

答案 0 :(得分:0)

表Licentie中的字段ExpiratieDatum是日期时间字段吗?

在这种情况下,它可能是格式问题 该服务以管理员帐户启动,该帐户的日期时间格式可能与启动update.exe时登录的用户不同。