一个关于Cannot modify a read-only dataset的问题,请高手帮忙,在线等!

hhdn 2006-07-18 09:56:32
各位大侠好,又是我,这次是一个修改按钮的问题,代码如下:
procedure Tfrminput.Button4Click(Sender: TObject);
var
date1:String;
begin
if Query1.Active = True then
if (Trim(Edit1.Text)<>'')and(Trim(Edit2.Text)<>'')then
with Query1 do
begin
Try
Edit;
Query1.ParambyName('MC').AsString:=Trim(Edit1.Text); //工具名称
Query1.ParambyName('GG').AsString:=Trim(Edit2.Text); //工具规格
Query1.ParambyName('DFL').AsString:=Trim(Combobox1.Text); //大分类
Query1.ParambyName('XFL').AsString:=Trim(Combobox2.Text); //小分类
Query1.ParambyName('DW').AsString:=Trim(Edit3.Text); //单位
Query1.ParambyName('LR').AsInteger:=Strtoint(Trim(Edit4.Text)); //在库领入
Query1.ParambyName('MS').AsInteger:=Strtoint(Trim(Edit5.Text)); //磨损
Query1.ParambyName('SH').AsInteger:=Strtoint(Trim(Edit6.Text)); //损坏
Query1.ParambyName('DS').AsInteger:=Strtoint(Trim(Edit7.Text)); //丢失
Query1.ParambyName('DJ').AsInteger:=Strtoint(Trim(Edit8.Text)); //短借
Query1.ParambyName('CJ').AsInteger:=Strtoint(Trim(Edit9.Text)); //长借
Query1.ParambyName('KCSL').AsInteger:=Strtoint(Trim(Edit10.Text)); //库存数量
Query1.ParambyName('ZJC').AsInteger:=Strtoint(Trim(Edit11.Text)); //总结存
date1 :=FormatDateTime('yyyy-mm-dd',DateTimePicker3.Date); //格式化日期为年月日
Query1.ParambyName('RQ').value:=strtodate(date1);//登记日期
Query1.ParambyName('BZ').AsString:=Trim(Memo1.Text); //备注
Post;
Application.MessageBox('修改成功。','提示',0+64);
Except
Application.MessageBox('修改失败。','提示',0+64);
Close;
end;
end;
点击该按钮时报错:Cannot modify a read-only dataset;

我觉得是可能编辑一个readonly属性设置为True的TTable组建Table1时出现的问题,可是窗口中的DbGrid指向的datasource关联的是一个Query1,而不是一个表格啊,怎么会出现表格的readonly没设置成false的问题呢?难道query能形成一个表格么?那这个表格在哪儿?怎么把它的readonly属性设置成false呢?
请各位大侠帮忙,谢了!!!!挺着急的~
...全文
1844 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhdn 2006-07-19
  • 打赏
  • 举报
回复
谢谢,问题已经解决了,是用另一个query完成的修改任务,增加了若干个字符变量来帮忙~谢谢大家~
hhdn 2006-07-18
  • 打赏
  • 举报
回复
我就是想知道,错误提示的这个readonly到底是谁造成的?是query1得出的那个表么?
hhdn 2006-07-18
  • 打赏
  • 举报
回复
谢谢langzi,FieldName确实是我的一个疏忽,复制粘贴害死人啊!

不过,修改过来后,还是仍旧发生那个Cannot modify a read-only dataset;的错误~
langzi998 2006-07-18
  • 打赏
  • 举报
回复
procedure Tfrminput.Button4Click(Sender: TObject);
var
date1:String;
begin
if Query1.Active = True then
if (Trim(Edit1.Text)<>'')and(Trim(Edit2.Text)<>'')then
with Query1 do
begin
Try
Edit;
FieldByName('MC').AsString:=Trim(Edit1.Text); //工具名称
FieldByName('GG').AsString:=Trim(Edit2.Text); //工具规格
FieldByName('DFL').AsString:=Trim(Combobox1.Text); //大分类
FieldByName('XFL').AsString:=Trim(Combobox2.Text); //小分类
FieldByName'DW').AsString:=Trim(Edit3.Text); //单位
FieldByName('LR').AsInteger:=Strtoint(Trim(Edit4.Text)); //在库领入
FieldByName('MS').AsInteger:=Strtoint(Trim(Edit5.Text)); //磨损
FieldByName('SH').AsInteger:=Strtoint(Trim(Edit6.Text)); //损坏
FieldByName('DS').AsInteger:=Strtoint(Trim(Edit7.Text)); //丢失
FieldByName('DJ').AsInteger:=Strtoint(Trim(Edit8.Text)); //短借
FieldByName('CJ').AsInteger:=Strtoint(Trim(Edit9.Text)); //长借
FieldByName('KCSL').AsInteger:=Strtoint(Trim(Edit10.Text)); //库存数量
FieldByName('ZJC').AsInteger:=Strtoint(Trim(Edit11.Text)); //总结存
date1 :=FormatDateTime('yyyy-mm-dd',DateTimePicker3.Date); //格式化日期为年月日
FieldByName('RQ').value:=strtodate(date1);//登记日期
FieldByName('BZ').AsString:=Trim(Memo1.Text); //备注
Post;
Application.MessageBox('修改成功。','提示',0+64);
Except
Application.MessageBox('修改失败。','提示',0+64);
Close;
end;
end;



注意看一下不同的地方
langzi998 2006-07-18
  • 打赏
  • 举报
回复
把源程序Email给我帮你看看
hhdn 2006-07-18
  • 打赏
  • 举报
回复
寒楼上一个,Query1有readonly属性么?
langzi998 2006-07-18
  • 打赏
  • 举报
回复
把Query1的readonly设置成false就可以了
hhdn 2006-07-18
  • 打赏
  • 举报
回复
有人能帮帮忙么?
npkaida 2006-07-18
  • 打赏
  • 举报
回复
给 Query1 加一个 TUpdateSQL,设置好属性即可。
hhdn 2006-07-18
  • 打赏
  • 举报
回复
有高手知道么?请帮忙啊~谢谢了!
hhdn 2006-07-18
  • 打赏
  • 举报
回复
是SQLserver2000
亮剑_ 2006-07-18
  • 打赏
  • 举报
回复
什么数据库,如果是文件型的(Flat File)如Paradox或Access,会不会数据库文件是只读的
Universal Data Access Components History unidac@devart.com 7.4.12 21-Jan-19 Bug with using the datetime literals in SQL statements in TVirtualQuery is fixed Bug with AV failure in the Refresh method in RAD Studio 10.2 Tokyo on Linux is fixed Oracle data provider Bug with authentication of old users in Oracle 12c is fixed Bug with the DML arrays that contain the TIMESTAMP values is fixed Bug with describe of SYNONYM for stored procedures in the Direct mode is fixed Bug with fetch data when the FieldsAsString option is set to True in the Direct mode is fixed Bug with open REFCURSOR is fixed SQLServer data provider Bug with the "Cannot modify a read-only dataset" error in Android is fixed MySQL data provider Bug with setting the data type of the parameter to BOOLEAN for all TINYINT system data types in the functions is fixed PostgreSQL data provider Bug with reading and writing of the floating point values is fixed InterBase data provider Bug with using the AsBytes property is fixed Bug with the AV failure when using the BLOB data type in Lazarus is fixed SQLite data provider Now the Direct mode is based on the SQLite engine version 3.26.0 DBF data provider Bug with wrong selection of deleted records is fixed Bug with storing numeric values is fixed Bug with using the CTOD, DTOC, DTOS, TTOC, TTOD and EMPTY functions in index expressions is fixed Bug with using a field named RECNO in the index expressions is fixed MongoDB data provider Bug with reading string values in the BSON format is fixed NexusDB data provider Bug with missing files for NexusDB for RAD Studio Rio (10.3) is fixed ODBC data provider The UnknownAsSring specific option is added

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧