报错 标准表达式中数据类型不匹配,如何解决;

ekin 2003-09-13 09:17:01
var
time1:string;
tt1,tt2,T,G,ph,dt,rs,rscy : string;
begin
time1:=DateTimeToStr(Now);
tt1:=edt_tt1.Text;
tt2:=edt_tt2.Text;
T:=edt_t.Text;
G:=edt_g.Text;
ph:=edt_ph.Text;
dt:=edt_dt.Text;
rs:=edt_rs.Text;
rscy:=edt_rscy.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(' insert into sj ');
adoquery1.SQL.Add('( 时间,进口温度,出口温度,蒸汽温度,流量,PH,电导率,污垢热阻,采样计算 )');
adoquery1.SQL.Add(' values ');
adoquery1.SQL.Add('('''+time1+''','''+tt1+''','''+tt2+''','''+T+''','''+G+''','''+ph+''','''+dt+''','''+rs+''','''+rscy+''')');
adoquery1.ExecSQL;


end;


报错 标准表达式中数据类型不匹配,如何解决;
数据库中time1为时间类型,其余为双精度数
...全文
214 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxpbuaa 2003-09-13
  • 打赏
  • 举报
回复

adoquery1.ExecSQL;
放在:
with ADOQuery1.Parameters do
begin
……
end;
之后。

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
ekin 2003-09-13
  • 打赏
  • 举报
回复
我将其放在时间时间里,但结果数据插入不了数据库中,插入的数据总是为空


procedure Tfrm_system.Timer1Timer(Sender: TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(' insert into sj ');
adoquery1.SQL.Add('( 时间,进口温度,出口温度,蒸汽温度,流量,PH,电导率,污垢热阻,采样计算 )');
adoquery1.SQL.Add(' values ');
adoquery1.SQL.Add('(:time1,:tt1,:tt2,:T,:G,:ph,:dt,:rs,:rscy)');
adoquery1.ExecSQL;
with ADOQuery1.Parameters do
begin
ParamByName('time1').Value := Now;
if edt_tt1.Text<>''then begin
ParamByName('tt1').Value := StrToFloat(edt_tt1.Text); end;
if edt_tt2.Text<>''then begin
ParamByName('tt2').Value := StrToFloat(edt_tt2.Text);end;
if edt_t.Text<>''then begin
ParamByName('T').Value := StrToFloat(edt_t.Text);end;
if edt_g.Text<>''then begin
ParamByName('G').Value := StrToFloat(edt_g.Text);end;
if edt_ph.Text<>''then begin
ParamByName('ph').Value := StrToFloat(edt_ph.Text);end;
if edt_dt.Text<>''then begin
ParamByName('dt').Value := StrToFloat(edt_dt.Text);end;
if edt_rs.Text<>''then begin
ParamByName('rs').Value := StrToFloat(edt_rs.Text);end;
if edt_rscy.Text<>''then begin
ParamByName('rscy').Value := StrToFloat(edt_rscy.Text);end;
end;
end;


望赐教
lxpbuaa 2003-09-13
  • 打赏
  • 举报
回复
用参数啊,例如:

adoquery1.SQL.Add(' insert into sj ');
adoquery1.SQL.Add('(时间,进口温度) values(:V1, :V2)');
with ADOQuery1.Parameters do
begin
ParamByName('V1').Value := Now;
ParamByName('V2').Value := StrToFloat(edt_tt1.Text);
end;

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
lxpbuaa 2003-09-13
  • 打赏
  • 举报
回复
用参数啊,例如:

adoquery1.SQL.Add(' insert into sj ');
adoquery1.SQL.Add('(时间,进口温度) values(:V1, :V2)');
with ADOQuery1.Parameters do
begin
ParamByName('V1').Value := Now;
ParamByName('V2').Value := StrToFloat(edt_tt1.Text);
end;

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
ekin 2003-09-13
  • 打赏
  • 举报
回复
在数据库中是日期时间类型access 其余为双精度数。
tqtang 2003-09-13
  • 打赏
  • 举报
回复
time1为时间类型??

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧