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))) + ',')这句的问题。
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))) + ',')这句的问题。
是ORACLE就用SYSDATE
SQL.Add(':Time‘);
adoquery1.parameters.parambyname('time').value:=StrToDateTime(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now));
SQL.Add('Time=' + #39 + DateTimeToStr(StrToDateTime(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now))) + #39 + ',');
AdoQuery1.Parameters.ParamByName('time').Value:=StrToDateTime(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now));
SQL.Add('Time=#' + DateTimeToStr(StrToDateTime(FormatDateTime('yyyy-mm-dd hh:nn:ss', Now))) + '#,');
还是不行,提示出错:
Project Safty.exe are raised exception class EoleException with message 'Parameter 对象被不正确的定义。提供了不一致或不完整的信息。' Process stopped. Use Step or Run to continue
SQL.Add('update table1 set field_time = ''' + FormatDateTime('yyyy-mm-mm hh:ss:mm',now) + ''' ');
这样就没有问题了吧.这个问题我曾经也遇到过,不过有时不加''号还可以通过.