数据查询出错,快帮我看看(100分)

  • 主题发起人 主题发起人 yyss
  • 开始时间 开始时间
Y

yyss

Unregistered / Unconfirmed
GUEST, unregistred user!
with adoquery1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Close;<br>&nbsp; &nbsp; &nbsp; SQL.Clear;<br>&nbsp; &nbsp; &nbsp; SQL.Add('update tb_bmljzs SET<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bzrs=(select count from tb_main where danwei=:dw and bzcy='是'),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bzzs=(select avg(ljzs) from tb_main where danwei=:dw and bzcy='是'),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ljrs=(select count from tb_main where danwei=:dw and ljzs&gt;=8),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bjlrs=(select count from tb_main where danwei=:dw and (ljzs&gt;=6 and ljzs&lt;8)),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blrs=(select count from tb_main where danwei=:dw and ljzs&lt;6),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sjrs=(select count from tb_main where danwei=:dw and (ljzs&gt;=7 and ljzs&lt;8)),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ejrs=(select count from tb_main where danwei=:dw and (ljzs&gt;=6 and ljzs&lt;7)),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yjrs=(select count from tb_main where danwei=:dw and ljzs&lt;6)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where danwei=:dw');<br>&nbsp; &nbsp; &nbsp; parameters.ParamByName('dw').Value:='%'+Trim(edit1.Text)+'%';<br>&nbsp; &nbsp; &nbsp; open;<br>&nbsp; &nbsp; end;
 
查询语句不连上就提示错误,连上提示'是'是非法字符,搞不懂,帮帮忙指点指点。
 
SqlText := ' &nbsp;bzcy=''是'' &nbsp;'
 
with adoquery1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Close;<br>&nbsp; &nbsp; &nbsp; SQL.Clear;<br>&nbsp; &nbsp; &nbsp; SQL.Add('update tb_bmljzs SET<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bzrs=(select count from tb_main where danwei=:dw and bzcy=''是''),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bzzs=(select avg(ljzs) from tb_main where danwei=:dw and bzcy=''是''),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ljrs=(select count from tb_main where danwei=:dw and ljzs&gt;=8),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bjlrs=(select count from tb_main where danwei=:dw and (ljzs&gt;=6 and ljzs&lt;8)),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blrs=(select count from tb_main where danwei=:dw and ljzs&lt;6),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sjrs=(select count from tb_main where danwei=:dw and (ljzs&gt;=7 and ljzs&lt;8)),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ejrs=(select count from tb_main where danwei=:dw and (ljzs&gt;=6 and ljzs&lt;7)),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yjrs=(select count from tb_main where danwei=:dw and ljzs&lt;6)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where danwei=:dw');<br>&nbsp; &nbsp; &nbsp; parameters.ParamByName('dw').Value:='%''+Trim(edit1.Text)+''%';<br>&nbsp; &nbsp; &nbsp; open;<br>&nbsp; &nbsp; end;
 
非法字符问题解决,谢谢两位。但仍有错误,提示“不正常地定义参数对象,提供了不一致或不完整的信息”,是不是update语句有问题。除bzzs和ljzs是float数据类型外,其他都是int型。
 
bzrs=(select count from tb_main where danwei=:dw and bzcy=''是''),<br>bzzs=(select avg(ljzs) from tb_main where danwei=:dw and bzcy=''是''),<br>这里也写成传参数的方式,试试。
 
估计是你多个同名参数的问题,好好检查一下,建议你使用格式化字符串的方法。
 
问题解决,谢谢大家。<br>总结:<br>1、gulang正确,不要使用多个同名参数,用一个参数赋值是不可以的。<br>2、hhjjhhjj正确,把'是'转换为参数赋值解决问题,但原理还是没有搞明白,懂的吱一声哈。<br>3、对tandxu、々飞翔鸟々表示感谢,但答案错误,决定这次不给分。
 
后退
顶部