代码如下:运行出错。实在算不清timetostr这里要多少个单引号了。请大家帮帮忙,非常感谢。
DM1.adoplay.SQL.Add('select * from '+main.mbtext+'where 时间='''+timetostr(now())'''');

解决方案 »

  1.   

    DM1.adoplay.SQL.Add('select * from '+main.mbtext+'where 时间='+''''+timetostr(now())+'''')这样试试
      

  2.   

    DM1.adoplay.SQL.Add('select * from '+main.mbtext+'where 时间 = '+ #39 + timetostr(now()) + #39 ');
      

  3.   

    ('select * from '+main.mbtext+' where 时间='+Quotedestr(timetostr(now())));
      

  4.   

    不知道多少个多打几个不要紧,然后ShowMessage(sql.Text);来看下语句引号多哪个,再去掉
      

  5.   

    Format和QuotedStr配合起来必须的。
    DM1.adoplay.SQL.Add(Format('select * from %s where 时间 =%s;',[main.mbtext,Quotedestr(timetostr(now()))]) );
      

  6.   

    DM1.adoplay.SQL.Add('select * from '''+main.mbtext+''' where 时间='''+timetostr(now())+'''');
    这样就对了
      

  7.   

    纠正下
    DM1.adoplay.SQL.Add('select * from '+main.mbtext+' where 时间='''+timetostr(now())+'''');
    这样就对了
      

  8.   

    下回这样带引号的Sql最好Format一下sSql:=Format('select * from table where code=%d,name=''%s''',[nCode,sName]);
      

  9.   


    DM1.adoplay.SQL.Add('select * from '+main.mbtext+' where 时间='''+timetostr(now())'''');引号个数没错,存在两个问题:
    1,where 前少一个空格。
    2,timetostr(now()) 格式为 12:30:25 也就是说包含秒在内,估计你数据库里的‘时间’不含秒,
       所以查询出来的记录数可能为 0。
      

  10.   

    中间的单引号用双引号代替试试
    ACCESS数据库的SQL语句可以这样用