用query访问sqlserver为什么说table is read only?(急)(100分)

  • 主题发起人 主题发起人 vigour
  • 开始时间 开始时间
V

vigour

Unregistered / Unconfirmed
GUEST, unregistred user!
我用query查询一个表,因为我就想在dbgrid中直接修改,所以将requestlive设为true,但系统出错"table is readonly".
很奇怪,sql语句如是"select * from main"时,一点问题没有;但如果我改为
"select id 合同号 from main"就会错.而我想在表格中字段名显示为中文.
我是在程序一执行就运行这个query,应该不存在query间的冲突.
这个问题已经困扰了我多时,现在我都快急死了,只好来求求各位大虾了.
或者还有什么更好的方法来修改表中的数据,能和dbgrid一样简单直观,又不用
自己写许多代码.
谢谢!
 
清参见已答问题
 
如果你的代码只有这一点(select id 合同号 from main)应该不会出错的,应可以
修改,真的只这一个表吗?
以下是localsql关于select语句是否可以修改的说明。

Single-table queries

Queries 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 queries

All queries that join two or more tables will produce a read-only result set.

我觉得你的问题不一定非要转换fieldname吧,用个field.displaylabel或
title.caption什么的应该可以的。
 
所有的多表查询都返回只读数据集
你的例子我在SQL Server 7.0上调试通过没问题
 
参见已答<A HREF="http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=41965">问题</A>,相信对你有帮助.
 
加上UpdateSql
 
接受答案了
 
还不结束?
 
多人接受答案了。
 
后退
顶部