SQL.Add('select * from Friend_Tab where U_Code = ' +
        QuotedStr(Combobox1.text)) and
        F_Name = '(QuotedStr(Edit1.text);总是写不对,请教下,谢谢!!

解决方案 »

  1.   

    SQL.Add('select * from Friend_Tab where U_Code = ''' +
            Combobox1.text +''' and '+
            'F_Name = '''+(QuotedStr(Edit1.text)+'''');
      

  2.   

    SQL.Add('select * from Friend_Tab where U_Code = ' +
            QuotedStr(Memo1.text) +#10+'and'+#10+
            'F_Name ='+ QuotedStr(Edit1.text));
      

  3.   

    在Delphi里写这些语句,总是那个'在作怪。我的经验是,被赋值的一这如果是数字,直接写上,如('where ID=1'), 如果是字符型的,要加两个'',即
    ('where F_Name=''王五'''),如果引用如EDIT里面的值,则要加三个''',即:
    ('where F_Name='''+Edit1.Text+''''')。当然,查询时在不同的表内不一定成功。原因是使用的通配符不一样。在Access表中写成:
    ('where F_Name like '''+Edit1.Text+'*'+'''')
    在interbase库和Ma Sql里则写成:
    ('where F_Name like '''+Edit1.Text+'%'+'''')
    Please try it yourself and test it.
      

  4.   

    Well, 100 Score always be answered quickly.
      

  5.   

    SQL.Add('select * from Friend_Tab where U_Code = ' +
            QuotedStr(Combobox1.text)) +'and' +
            'F_Name = '+(QuotedStr(Edit1.text);
      

  6.   

    var
      sqlstr: string;
    sqlstr := 'select * from Friend_Tab where U_Code = ''' +
            (QuotedStr(Combobox1.text)) and
            F_Name = '+(QuotedStr(Edit1.text));
    SQL.Add(sqlstr);
      

  7.   

    var
      sqlstr: string;
    sqlstr := 'select * from Friend_Tab where U_Code = :U_Code and F_Name=:F_Name';
    sql.add(sqlstr);
    sql.parambyname('U_Code').asstring:=QuotedStr(Combobox1.text);
    sql.parambyname('F_Name').asstring:=QuotedStr(Edit1.text);
      

  8.   

    SQL.Add('select * from Friend_Tab where U_Code = ' 
            +' QuotedStr(Combobox1.text) and ' 
            +'F_Name = '''+(QuotedStr(Edit1.text)+''')';
      

  9.   

    注意它< '>以后编程时养成好的习惯,还有你应该好好的掌握SQL的句法,前面的高手们都说的很好了,祝你成功!
      

  10.   

    SQL.Add('select * from Friend_Tab where U_Code = ''' +
            QuotedStr(Combobox1.text) +'''and ' +
            'F_Name = '''+QuotedStr(Edit1.text)+'''');
      

  11.   

    SQL.Add('select * from Friend_Tab where U_Code = ''' +
            Combobox1.text +''' and '+
            'F_Name = '''+(QuotedStr(Edit1.text)+'''');
      

  12.   

    建议用sqlstring=sql语句sql.add(sqlstring);
    查询,插入记录都可以