谁能帮我!我实在是不知道该怎么做了!

shunv 2000-01-11 02:51:00
程序是这样的:
if not dmZu.dsDep.DataSet.IsEmpty then
begin
dmZu.dsDep.DataSet.Close;
dmZu.dsDep.DataSet.Open;
dmZu.tbDep.First;
while not dmZu.tbDep.Eof do
begin
aDepID:=dmZu.tbDep.FieldByName('DEPT_ID').AsInteger;这段程序的死循环就在这里;
aSupID:=dmZu.tbDep.FieldByName('SUP_DEPT_ID').AsInteger;
if dmZu.tbDep.FieldByName('DEPT_ID').AsInteger=0 then
begin
Child1:=TV.Items.AddChild(TreeNode1,dmZu.dsDep.DataSet.FieldByName('DEPT_NAME').AsString);
.
.
.
dmZu.dsP_D.DataSet.First;
while not dmZu.dsP_D.DataSet.Eof do
begin
if dmZu.dsP_D.DataSet.FieldByName('DEPT_ID').AsInteger=aDepID then
begin
aPosID:=dmZu.dsP_D.DataSet.FieldByName'POSITION_ID').AsInteger;
if dmZu.dsPos.DataSet.Locate('POSITION_ID',aPosID,[loCaseInsensitive]) then
sPos:=dmZu.dsPos.DataSet.FieldByName('POS_NAME').AsString;
TV.Items.AddChild(Child1,sPos);
end;
dmZu.dsP_D.DataSet.Next;
end;
end else
begin
.
.
end;
dmZu.tbDep.Next;
end;
end;
我是过了用dataset ,table 都不可以;我用断点调试,在执行了dmZu.tbDep.Next;这句后,数据库的指针还是指向第一条记录.在这之前没有对该dataset的操作.只有对其他dataset的操作,但是于它没有关系.谁可以告诉我,这还可能是由于什么原因?我是没有办法了,这个问题已经困扰了我两天了.谢谢!
...全文
192 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
barton 2000-01-13
  • 打赏
  • 举报
回复
这事与表间关系没有关系,我认为最有效率的做法是:
1.数据集用一个带排序的查询实现;
2.数据集只需从头到尾扫描一遍;
3.每生成一个结节,在结点处的DATA中连接一个对象(或者一个ID号)
4.生成新结点时通过已生成的结点所带的对象或ID号找出父结点.
Venne 2000-01-11
  • 打赏
  • 举报
回复
如果设置了主从关系的话,那么当主表移动到一定位置时,子表会自动更新记录集,你的这个表是不是别的什么表的子表呢?
shunv 2000-01-11
  • 打赏
  • 举报
回复
在程序里没有引用完整性.但是在数据库中,有其他的表和他又参照关系,这有影响吗?
Venne 2000-01-11
  • 打赏
  • 举报
回复
你有没有其他表与这个表有引用完整性或者设置了主从关系,比如MASTERSOURCE什么的,最好能看看你的源码?KXY说得对,把其它东西过滤掉再看一下.
kxy 2000-01-11
  • 打赏
  • 举报
回复
把其它的注释掉,只留下
Table.First
while not Table.Eof do
begin
其它Table的while;
Table.Next;
end;
试试
kxy 2000-01-11
  • 打赏
  • 举报
回复
源码好像没有问题
Implements a generic method to position the cursor on the next record in the dataset.

procedure Next;

Description

Do not call Next at the TDataSet level. In TDataSet descendants, call Next to position the cursor on the next record in the dataset and make it the current record. Next posts any changes to the current record and:

?Sets the Bof and Eof properties to False.
?Calls a virtual, abstract method to move to the next record, position the cursor on it, and make it the current record. For TDataSet this method is only declared, not implemented.
?Fetches any additional records required for display, such as those needed to fill out a grid control. In TDataSet this method calls another virtual, abstract method that is only declared, not implemented.
?Sets the Eof properties to True if the cursor was already on the last record in the dataset.

?Triggers an event handler for dataset scrolling events.

kxy 2000-01-11
  • 打赏
  • 举报
回复
请把Source发到kxy@csdn.net

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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