有这么一段代码:
dm.sqlllhead.Close;
dm.sqlllhead.SQL.Clear;
if a='2' then
dm.sqlllhead.SQL.Add('select a.llcode,a.llbm,a.bwlvs,a.isjg,a.jgbm,a.toolr,a.kostl,a.yt ,a.bz,a.llr,
b.spr from llhead a left join spjl b on a.llcode=b.llcode where a.llcode=:llcode and b.type=''Y'' and appstatus=''同意'')
else
dm.sqlllhead.SQL.Add('select a.llcode,a.llbm,a.bwlvs,a.isjg,a.jgbm,a.toolr,a.kostl,a.yt ,a.bz,a.llr,b.spr from llhead a left join spjl b on a.llcode=b.llcode where a.llcode=:llcode');
dm.sqlllhead.Parameters.ParamByName('llcode').Value:=b;
dm.sqlllhead.Open;
a和b都是有具体值的,但是当程序运行第一个select时,程序正常,当运行第二个select时,出现一个出错提示“an unknow error has occures”!
第一个select语句与第二个select语句只相差后面的两个条件有或者没有!
不知错在哪里?
请高手们帮忙!谢谢
dm.sqlllhead.Close;
dm.sqlllhead.SQL.Clear;
if a='2' then
dm.sqlllhead.SQL.Add('select a.llcode,a.llbm,a.bwlvs,a.isjg,a.jgbm,a.toolr,a.kostl,a.yt ,a.bz,a.llr,
b.spr from llhead a left join spjl b on a.llcode=b.llcode where a.llcode=:llcode and b.type=''Y'' and appstatus=''同意'')
else
dm.sqlllhead.SQL.Add('select a.llcode,a.llbm,a.bwlvs,a.isjg,a.jgbm,a.toolr,a.kostl,a.yt ,a.bz,a.llr,b.spr from llhead a left join spjl b on a.llcode=b.llcode where a.llcode=:llcode');
dm.sqlllhead.Parameters.ParamByName('llcode').Value:=b;
dm.sqlllhead.Open;
a和b都是有具体值的,但是当程序运行第一个select时,程序正常,当运行第二个select时,出现一个出错提示“an unknow error has occures”!
第一个select语句与第二个select语句只相差后面的两个条件有或者没有!
不知错在哪里?
请高手们帮忙!谢谢
begin -----!!!
dm.sqlllhead.SQL.Add('select a.llcode,a.llbm,a.bwlvs,a.isjg,a.jgbm,a.toolr,a.kostl,a.yt ,a.bz,a.llr,b.spr from llhead a left join spjl b on a.llcode=b.llcode where a.llcode=:llcode');
dm.sqlllhead.Parameters.ParamByName('llcode').Value:=b;
end; -----!!!
差个begin end;
dm.sqlllhead.Parameters.ParamByName('llcode').Value:=b;
不支持,BDE可以。
改为:
dm.sqlllhead.SQL.Add('select a.llcode,a.llbm,a.bwlvs,a.isjg,a.jgbm,a.toolr,a.kostl,a.yt ,a.bz,a.llr,b.spr from llhead a left join spjl b on a.llcode=b.llcode where a.llcode='+#39+yourParamValue+#39);
else后面就一条select语句;
这条语句:dm.sqlllhead.Parameters.ParamByName('llcode').Value:=b;不管在什么状态下都要运行的,不需要begin...end!
open;
append(edit);
dm.sqlllhead.Parameters.ParamByName('llcode').Value:=b;
post;
你的方法我也试过,也是出现同样的错误。
现在更奇怪的是:我在DELPHI环境中运行会出现错误,如果直接运行.exe文件则没有出现错误!搞不懂!
二楼的,ADO支持参数的