adoset1: TADODataSet   strname:='经销商';
   adoset1.commandtext:='select * from itemright where item_caption ="'+strname+'"';
   adoset1.open;可运行时总是提示我列名'经销商'无效,可strname只是用来查询的值,为何提示列名无效?

解决方案 »

  1.   

    where item_caption = '''+strname+'''';
      

  2.   

    query1.Close;
    query1.SQL.Clear;
    query1.SQL.add('select * from gz_jbqk where c50='''+combobox1.text+''' 
    and c51='''+combobox2.text+'''');
    query1.open;参考一下,是三个单引号!
      

  3.   

    楼上请问一下,delphi中对于引号有什么要求吗,单引号'和双引号"?
      

  4.   

    在SQL语句里,如果要添加双引号("),则应该写成 '"' ,若要添加单引号(')则应该写成'''。
      

  5.   

    我是Delphi beginner,关注ing
      

  6.   

    不是Delphi对"有要求,而在于SQL中要用单引号作字符串的分界符.
      

  7.   

    试一试where item_caption =quotedstr(strname);
      

  8.   

    query1.SQL.add('select * from gz_jbqk where c50='+QuotedStr(combobox1.text)+' 
    and c51='+QuotedStr(combobox2.text));
    用quotedstr会标准一些
      

  9.   

    1种:
    var:strname:char;
    begin
    strname:='经销商';
    commandtext:='select * from itemright where item_caption='''+strname+'''';
    adoquery1.open;
    2种
    //combobox1.text:='经销商';
    combobox1.text:='经销商';
    commandtext:='select * form itemright where item_caption='''+combobox1.text+'''';
    adoquey1.open;
      

  10.   

    打开 tools---editor options---选择最后一页code insight,把那几个checkbox都选上,确定.
    试试看
      

  11.   

    谢谢sandman,不过你说的不是我要的,我的问题是在编程过程中定义edt1:Tedit,如输入edt1. 则会出现提示框显示edt1的方法及属性,但现在却不提示了?