SQL问题--Update出错!!!时间和字符串转换的问题!!!!
if FormMain.ADOConnection1.Connected then
begin
with FormMain.ADOQuery4 do
begin
if Active then
Close;
SQL.Clear;
SQL.Add('UPDATE Information SET');
SQL.Add('Time=' + DateTimeToStr(StrToDateTime(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now))) + ',');
// SQL.Add('Time=' + DateTimeToStr(Now) + ',');
SQL.Add('CH4Concent=' + FloatToStr(concent) + ',');
SQL.Add('pressure=' + FloatToStr(pressure) + ',');
SQL.Add('tfl=' + FloatToStr(tfl));
SQL.Add('WHERE' +'(CoalID=' + #39 + coalid + #39 + ') And' + '(WorkID=' + #39 + workid + #39 + ') And' + '(DeviceID=' + #39 + deviceid + #39 + ')');
try
ExecSQL;
except
exit;
end;
end;
end;
程序运行后出错:
Project Safty.exe are raised exception class EoleException with message 'Parameter 对象被不正确的定义。提供了不一致或不完整的信息。' Process stopped. Use Step or Run to continue
请各位大虾帮帮忙看看该如何修改!
我用单步调试时,发现是SQL.Add('Time=' + DateTimeToStr(StrToDateTime(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now))) + ',')这句的问题。