如果数据库名和字段名没错的话,这句SQL没有问题

解决方案 »

  1.   

    没有问题的,贴出你的error code
      

  2.   

    在QUERY1的sql属性为出现:
    invalid use of keyword
    token:size
    line number:1
      

  3.   

    解决办法:select * from animals或者select name,weight from animals
    只要不单独在select 中写入size字段就不会有问题,即使你写select name,weight,area
    from animals也不会出问题的。
      

  4.   

    这一句我直接在SQL SERVER中的查询分析器中运行是不会错的.
    你可以用'select name,[size],weight from animals'来避免上述错误
    以后如果列名为关键字可含有空格时,都可以加上"[]"来避免冲突/**************************************/
    /*              学无止境              */ 
    /**************************************/
      

  5.   

    是的,运行时size加[]也不行,只要有size字段,就出错
      

  6.   

    看来是因为和DELPHI关键字冲突了,有办法了:
    用'select animals.name,animals.size,animals.weight from animals'
    这样还不行才怪呢
    /**************************************/
    /*              学无止境              */ 
    /**************************************/
      

  7.   

    多谢黄志文,只可惜你的方法还是不行,我也算是老手,教学弟最简单的sql,不注意把自己给tao住了,麻烦你亲自试一下再说,并(animals是dbdemos中的一个表,delphi自带的。size也不是关键字)。
      

  8.   

    你试过了没有??全加上""的内容是什么,全是'size','name','weight'而无数据
      

  9.   

    多谢zhiwen_huang(黄志文),Focus(老鱼),问题解决了,query1.SQL.Add('select name,weight,animals."size"  from animals');请收分!!
      

  10.   

    也许是因为是dbf数据库的原因
      

  11.   

    Below is an alphabetical list of words reserved by local SQL. Avoid using these reserved words for the names of metadata objects (tables, columns, and indexes). An "Invalid use of keyword error" occurs when reserved words are used as names for metadata objects. If a metadata object must have a reserved word as it name, prevent the error by enclosing the name in quotation s and prefixing the reference with the table name.
      

  12.   

    真不好意思,这么简单的问题都没帮上忙,不过DBDEMOS好象是Paradox数据库,只支持部分SQL-92语法,但你的方法是可行的.
    我在SQL SERVER上建了一张一样的表,用ADOQUERY试过,以下都可以
    select size from animals
    select animals.size from animals
    select [size] from animals跟你学了一招,谢谢
    /**************************************/
    /*              学无止境              */ 
    /**************************************/