Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select * from ub_LWXX where 类型='政治'');
Query1.Open;
执行到‘Query1.SQL.Add('select * from ub_LWXX where 类型='政治'');’就错误
[Error] frm_Lwxxgl.pas(231): Illegal character in input file: '政' ($D5FE)帮忙看看,我感觉我的语句是对的
这样就没错了。
注意引号个数
再换一个答案
uses
strutils;Query1.SQL.Add(Format('select * from ub_LWXX where 类型=%s',[QuotedStr('政治')]));
用这样的语句可以减少出错的概率,尤其是在参数比较多的时候
Query1.SQL.Add('select * from ub_LWXX where 类型='+chr(39)+'政治'+chr(39));