RT

解决方案 »

  1.   

    'select * from student where name='''
      +  edit1.text  
      + ''''这样是不是清楚一点??第一行第二个单引表转义
        ->  ''  转义一个'
      

  2.   

    Query1.SQL.Add('select * from student where name='''+edit1.text+'''');在Delphi字符串常量中 ''(两个紧连的单引号)表示字符 ',一个单引号表示字符串常量的开始或结束。
    这样如果Edit1.Text 的值为:Tom,则SQL字符串为:
    select * from student where name ='Tom'
      

  3.   

    如果Edit1.Text = 'Abc'那
    'select * from student where name='''
      +  edit1.text  
      + ''''就是select * from student where name='Abc' 
    等同于
    'select * from student where name="'
      +  edit1.text  
      + '"'
    ->select * from student where name="Abc"
      

  4.   

    sql中用两个单引号表示一个单引号,而你要用的是string类型又要一个单引号啊!
      

  5.   

    因为要查name = 'aaaa'的记录,第一个引号是转义字符,第二个是要输出的内容,输出的SQL是这样的:
    假设edit1.text = 'aaaa',那么就是select * from student where name='aaaa'(因为字符串要用单号)