要是谁把我的那个问题弄出来我给200分
要是想要我还可以多给100分

解决方案 »

  1.   

    我看是
    SQLScript:=Format('Select * from PresentTable where %s = "%s"', [combobox1.Text, Edit1.Text]);
    With ADODataSet do
        begin
          Active:=false;
          CommandText:=SQLScript;
          Prepared:=true;
          Active:=true;
          Prepared:=false;
        end;
      

  2.   

    给你个函数,Delphi自带的:QuotedStr()
      

  3.   

    我已写好了一个屏蔽单引号和相应规范的字符转换的Function, 请参考:
    function ChangeStarChar(sourStr : string): string ;
    var
         i : integer;
    begin
      sourStr:=StringReplace(sourStr,'_','[_]',[rfReplaceAll]);
      sourStr:=StringReplace(sourStr,'"','""',[rfReplaceAll]);
      sourStr:=StringReplace(sourStr,'''','',[rfReplaceAll]);
      while  pos('*',sourStr)>0 do
        sourStr[pos('*',sourStr)]:='%' ;
      result:=sourStr;
    end;
    当使用SQL语句前,做好一些准备工作
    var
      str1, str2: string;
    begin
      str1 := ChangeStarChar(combobox1.Text);
      str2 := ChangeStarChar(edit1.Text);
    ........
      adoquery1.SQL.add('select czy_dmid , czy_kl from xs_czy where czy_dmid='''+str1+'''and czy_kl ='''+str2+'''');
    .......
    end;我想这应该是你想要的结果吧?