关于BDE控件Table控件的一个问题? 急!!!

chengangcsdn 2004-09-16 06:41:56
DBGrid1的数据集由Table1提供,Table1的Tablename初始为:rs_temppay
其中在Table1的afterpost事件中:table1.refresh
其实我就是想实现:DBGrid1中输入数据 然后直接更新到后台数据中。
还有一个ComboBox1控件用来决定Table1连接后台数据中哪个表。
在ComboBox1的change事件中,切换Table1所连接表,
事件:
case combobox1.itemindex of
0:begin
table1.active:=false;
table1.tablename:='rs_temppay';
table1.active:=true;
table1.edit;
end;
1:begin
table1.active:=false;
table1.tablename:='rs_table';
table1.active:=true;
table1.edit;
end;
问题:在没有触发combobox1的change事件时可以修改DBGrid1中各字段的值,也能反应到后台数据库
但在触发combobox1的change事件后。报错:'Table does not support this operation because it is not uniquely indexed'
即使我所的表和初始表为同一个表时也会报这个错。
为什么报这个错误!我建了一个索引是唯一的。
怎么达到我想要的结果。
...全文
143 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wilowind 2004-09-16
  • 打赏
  • 举报
回复
试试 lockTable ,和UnlockTable
chengangcsdn 2004-09-16
  • 打赏
  • 举报
回复
TO qizhanfeng(glacier)
我想不会是我的索引的问题,因为我不触发combobox1的change事件就可以修改且能更新到后台数据库.
TO jiang5460(巴山夜雨)
不行。
大家顶顶吧!急啊~~~~~~~~~~~~~~~~~
jiang5460 2004-09-16
  • 打赏
  • 举报
回复
你在事件On show哪边让他Fasle;
qizhanfeng 2004-09-16
  • 打赏
  • 举报
回复
是不是还有其他的需要是唯一索引的字段不是唯一索引
另外我觉得要实现你的功能
只需要在form的onclosequery里
加句 if table1.State in [dsEdit,dsInsert] then Post;
就行
RX Library 2.75 =============== The Set of Native Delphi Components for Borland Delphi versions 1, 2, 3, 4 & 5 and Borland C++ Builder 1, 3 & 4. 100% Source Code. Last revision date Oct 12, 1999. PLEASE FOLLOW THE INSTRUCTIONS PROVIDED IN THE INSTALLATION SECTION! TABLE OF CONTENTS ----------------- Latest Changes Overview History License Agreement Installation Demonstration Programs Source Files Using GIF Images Copyright Notes NEW FOR VERSION 2.75 -------------------- Delphi 5.0 & C++Builder 4.0 Compatibility New components: TRxLoginDialog New properties, events: TFormPlacement.RegistryRoot TFormPlacement.Version TFontComboBox.UseFonts TRxDBGrid.OnTopLeftChanged TRxDBLookupCombo.DisplayValues TStrHolder.Macros, TStrHolder.OnExpandMacros RxSpin.TValueType.vtHex New routines, methods, constants: SaveClipboardToStream, LoadClipboardFromStream (clipmon.pas) AppFileName, AppVerInfo (rxverinf.pas) XorString, XorEncode, XorDecode (strutils.pas) BUG FIXES. Overview -------- RX Library contains a large number of components, objects and routines for Borland Delphi with full source code. This library is compatible with Borland Delphi 1, 2, 3, 4, 5 and Borland C++ Builder 1, 3, 4. This collection includes over 60 native Delphi components. RX Library is a freeware product. Feel free to distribute the library as long as all files are unmodified and kept together. The authors disclaim all warranties as to this software, whether express or implied, including without limitation any implied warranties of merchantability or fitness for a particular purpose. Use under your own responsibility, but comments (even critique) in English (or in Russian) are welcome. 1. Components: TRxDBLookupCombo provides an incremental search through lookup list by directly typing into the combo control while the lookup list is displayed, LookupSource can refer to TTable, TQuery, TRxQuery or TQBEQuery. It even incrementally searches on the query results and much more... TRx

828

社区成员

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

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