edit1.Text:=char(39); 实验一下就知道了

解决方案 »

  1.   

    等效于('select * from table where id=''' +edit1+ '''';
      

  2.   

    'select * from table where id=''' +edit1.text+ ''';在delphi中语法检查通不过的,所以'select * from table where id='+char(39)+edit1+char(39)
      

  3.   

    等效于('select * from table where id=' +edit1 ;
      

  4.   

    to taidy()
    'select * from table where id='''+edit1.text+'''';你少了引号,当然语法检查中通不过了,其实这样写是为了程序的可读性,因为'在DELPHI的物质性,换用char(39)或#39来代替,不过你只要记得在delphi中如果字符串中需要'时,必须写成''就行了,如以下这个字符串:
    'I''m a student,I am writing a char '''''' on the paper'
    其实就是 
    'I'm a student,I am writing a char ''' on the paper
      

  5.   

    'select * from table where id=''' +edit1.text+ ''';在delphi中语法检查通不过的,所以'select * from table where id='+char(39)+edit1+char(39)
      

  6.   

    'select * from table where id=''' + Edit1.Text + ''''; //这样不就可以了
    'select * from table where id='#39 + Edit1.Text + #39; //这样也可以
    //试想如果Edit1.Text有单引号,如上方法不就出错了吗?
    //建议使用
    Format('select * from table where id=%s, [QuotedStr(Edit1.Text)]);
    //quotedStr会处理包含单引号的情况
      

  7.   

    'select * from table where id=''' + Edit1.Text + ''''; //这样不就可以了
    'select * from table where id='#39 + Edit1.Text + #39; //这样也可以
    //试想如果Edit1.Text有单引号,如上方法不就出错了吗?
    //建议使用
    Format('select * from table where id=%s, [QuotedStr(Edit1.Text)]);
    //quotedStr会处理包含单引号的情况