补充一下:
索引书号是用SQLServer建的,类型是ntext.

解决方案 »

  1.   

    真是新手!
    if combobox1.Text='索引书号' then
    begin
        SQL.Text:='select * from book  where 索引书号.value='+form1.edit1.text;
        ……
        ……
    end;
      

  2.   

    sql.text:='select * from book  where 字段名='''+form1.edit1.text+'''
      

  3.   

    sql.clear;
    sql.add('select * from book where 字段名=:p');
    paramByName('p').AsString = form1.edit1.text;
    這樣寫清晰
      

  4.   

    我比较喜欢这种写法,在参数比较多的情况下看起来很清晰:with Query1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add(Format('select * from book where XXXX=''%s''', [Edit1.Text]));
    end;
      

  5.   

    ntext类型不能用’=‘,要用‘LIKE’你可以查以查SQL的帮助。
      

  6.   

    with datamodule2.Query1 do
      begin
        if active=true then
        close;
        unprepare;    if combobox1.Text='索引书号' then
        begin
          sql.clear;
          SQL.add('select * from book  where 索引书号.value=:xxx');  
          parambyname('xxx').asstring:=form1.edit1.text';
          prepare;
          open;
        end;
      end;