我用adotable或adoquery连接数据库更新记录时,老出错,更新到一定数据时就出错,提示大概如下:"key column....",程序没有语法错误,如下:while not adotable.eof do
begin
adotable.edit
adotable.fieldbyname('字段').asstring:='';
adotable.post;
adotable.next
end
begin
adotable.edit
adotable.fieldbyname('字段').asstring:='';
adotable.post;
adotable.next
end
解决方案 »
- 急,oracle blob 字段用sql语句要怎样才能插入到表中去?
- 为什么我从Delphi编写的界面的文本框中COPY的汉字,到了别的程序就变成了乱码?
- 记录类型文件的定义问题(固定长度Str1:String如何超过[255] )
- twebbrowser 怎么判断当前浏览页面不为空页面???????
- delphi连接informix问题????
- 制作控件事件的问题
- 使用Indy关于文件传输的问题
- 这个报表如何做?那些memo不太好处理
- 关于MDI关闭的问题
- 感谢zswang(伴水) coolslob() stiwind(海蜃),但copyfile()问题还是没有解决,而且出现新问题!!!
- 一段delphi代码转化为CBuilder
- 请用过wise installation的兄弟姐妹们帮个忙!急啊!
begin
adotable.edit
adotableName.Value := ''; // 比如字段对象的名称为 adotableName
adotable.post;
adotable.next
end建立字段对象的方法:DataSet控件(就是这里的adotable)上点右键,"Fields Editer",再"Add Fields"
adotable.first
////
while not adotable.eof do
begin
adotable.edit
adotable.fieldbyname('字段').asstring:='';
adotable.post;
adotable.next
end
多行被更新了,是不是你更新的这一个字段不能有重复的值?
第二,检查主键或唯一索引是否有冲突。
优化一些语句
adotable.disanblecontrol;
try
while not adotable.eof do
begin
adotable.edit
adotable.fieldbyname('字段').asstring:='';
adotable.next
end;
if adotable.STATE IN [dsEdit] then
adotable.POST;
finally
adotable.Eanblecontrol;
end;
还是建议你将adotable改换为TADODATASET
begin
adotable.edit
adotable.fieldbyname('字段').asstring:='';
adotable.post;
adotable.next
end
問題出在您每次edit之後post,這樣每次post之後,當前紀錄指針又為第一條紀錄,所以建議采用
樓上HZ_ZMD的方法
不能为空