如何使字符串带有'号?
比如
有一段SQL语句:select * from sysobjects where type = 'U'
j将该语句赋值给String类的str如何写语句?

解决方案 »

  1.   

    stringxxx := 'select * from sysobjects where type = ''U''';
      

  2.   

    写错了!应该是
    strSql := 'select * from sysobjects where '+
              ' type = '+
              ''''+'u'+'''';
      

  3.   

    strSql:='select * from sysobjects where type = '''+'U'+''''

    strSql:='select * from sysobjects where type = "U"'
      

  4.   

    strSql := 'select * from sysobjects where type = '+ '''u''';
      

  5.   

    字符串中两个单引号表示一个单引号strings := ''''; // strings的值:'
    strings := 's'''; // strings的值:s'
    strings := 's''s'; // strings的值:s's
      

  6.   

    stringxxx := 'select * from sysobjects where type = '+QuotedStr(U);
    QuotedStr加'的函数.
      

  7.   

    老兄,你居然不给分,怎么帮你啊
    用#39  代表单引号
    strSql := 'select * from sysobjects where type = '+ #39+#39+'u'+#39+#39;
      

  8.   

    你们写的都对啊。
    delphi中的字符串中的单引号'是用2个'来代表的,
    因此
    'select * from sysobjects where '+' type = '+''''+'u'+'''';
    =(把'+'去掉) 'select * from sysobjects where type= ''u''' ;
    此外,某些数据库的字符串是用双引号引起来的,因此,还可以写作
    (用"代替'') 'select * from sysobjects where type= “u”' ;