默认情况下,查询结果是只读的。应用程序可以用数据控件去显示查询结果,
但用户不能编辑数据。怎样才能使用户能够编辑数据呢?要使用户能够编辑数据
,必须把TQuery构件的RequestLive属性设为True。不过,把RequestLive属性
设为True并不能保证查询结果一定是可以修改的,因为这还取决于查询使用的是
Local SQL还是与服务器相关的SQL。像查询Paradox或dBASE以及异构查询都是
使用Local SQL,而查询远程服务器则使用与服务器相关的SQL。即使RequestLive
属性设为True,而且查询的是本地数据库,但由于SELECT语句的文法不合适,
BDE也将返回只读的查询结果。因此,在编辑数据之前,先要访问CanModify属性。
只有当这个属性返回True时,才表示查询结果是可编辑的。

解决方案 »

  1.   

    Single-table queriesQueries that retrieve data from a single table are updatable provided that:There is no DISTINCT key word in the SELECT.
    Everything in the SELECT clause is a simple column reference or a calculated column, no aggregation is allowed. Calculated columns remain read-only.
    The table referenced in the FROM clause is an updatable base table.
    There is no GROUP BY or HAVING clause.
    There are no subqueries in the statement.
    There is no ORDER BY clause.The read-only effect of an ORDER BY clause is negated and the query updatable if the ORDER BY clause uses a single column and there is a dBASE single-column primary or secondary index based on that same field. dBASE compound (expression) indexes will not negate the read-only effect of an ORDER BY clause. A Paradox single- or multi-field primary index will make the query updatable if the ORDER BY uses exactly the same columns (in the same order) as the index. Paradox secondary indexes will not negate the read-only effect of an ORDER BY clause.Multi-table queriesAll queries that join two or more tables will produce a read-only result set.
      

  2.   

    哈哈,楼上这个消息是英文的,其实说明的已经很明确,就是用select时用的参数跟结果是不是只读是有直接关系的,select命令帮助中有明确的提示,小菜我做过返回只读结果的query,但为了能修改,我用了另外一个query,把只读的东东赋给新的东东就可以修改了,哈哈,试试。也许能行。
      

  3.   

    对query的requestlive属性设置为真会不能修改,增加updatesql控件,设置cacheupdate为真就没有问题了!
      

  4.   

    对数据进行修改时,要先进行判断状态,即先进入编辑状态,打入
    ‘edit’语句。
      

  5.   

    我的query中的数据从不直接修改。修改的话用另一个query用SQL语句UPDATE。
    工作量并不大。(习惯了)