| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2288 人关注过本帖
标题:List index out of bounds的错误
只看楼主 加入收藏
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
收藏
 问题点数:0 回复次数:0 
List index out of bounds的错误

在调用一个adoquery查询语句的过程的时候出现这个错误,怎么改正啊?
大家看看,帮帮忙,谢谢先。具体的如下:
procedure TMessageDesignForm.FormShow(Sender: TObject);
begin
ShowDataForCQ;
ShowDataForYJ;
ShowDataForLS;
SetState(vShow); //设置当前状态为显示数据状态
SetState(vMoneyOK);
end;
这个是我一打开MessageDesignForm然后在DBGrid中显示数据的程序,
ShowDataForCQ;
ShowDataForYJ;
ShowDataForLS;
这三个过程在下面给出,只是把数据库的信息读到DBGrid中而已;
SetState(vShow); //设置当前状态为显示数据状态
SetState(vMoneyOK);
这两个古过程也在下面给出,就是设置,一下界面上控件在什么状态的时候显示为可写,什么时候为只读的。
程序运行后,要打开MessageDesignForm的时候,会出现List index out of bounds的错误,
错误是在FormShow中,我不写FormShow就不会出错,为什么呢?

//*****************在DBGridCQ,LS,YJ中显示客户数据表中信息*************************
procedure TMessageDesignForm.ShowDataForCQ;
begin
adoqueryCQ.SQL.Clear;
adoqueryCQ.SQL.Text:='select cqkhid as ID,cqkhxm as 姓名,cqcph as 车牌号,cqckh as 车库号,cqckqx as 持卡期限,cqkhzz as 住址,cqtel as 电话,cqvalue as 费用,cqtype as 持卡类型,cqbkh as 补卡号,cqrktime as 入库时间,cqcktime as 出库时间 from 长期客户管理 ';
try
adoqueryCQ.Open;
except
showmessage('访问数据库失败,请重新启动应用程序');
Application.Terminate;
exit;
end;
DBGridCQ.Columns[0].Width:=50;
DBGridCQ.Columns[1].Width := 80;
DBGridCQ.Columns[2].Width := 80;
DBGridCQ.Columns[3].Width := 80;
DBGridCQ.Columns[4].Width := 100;
DBGridCQ.Columns[5].Width := 80;
DBGridCQ.Columns[6].Width := 80;
DBGridCQ.Columns[7].Width := 80;
DBGridCQ.Columns[8].Width := 80;
DBGridCQ.Columns[9].Width := 80;
DBGridCQ.Columns[10].Width := 80;
DBGridCQ.Columns[11].Width := 80;
end;
procedure TMessageDesignForm.ShowDataForLS;
begin
adoqueryLS.Close;
adoqueryLS.SQL.Clear;
adoqueryLS.SQL.Text:='select lskhid as ID,lskhxm as 姓名,lsckh as 车库号,lscph as 车牌号,lsbkh as 补卡号,lstype as 持卡类型,lsrktime as 入库时间,lscktime as 出库时间,lsvalue as 费用 from 临时客户管理';
try
adoqueryLS.Open;
except
showmessage('访问数据库失败,请重新启动应用程序!');
Application.Terminate;
exit;
end;
DBGridLS.Columns[0].Width:=50;
DBGridLS.Columns[1].Width := 80;
DBGridLS.Columns[2].Width := 80;
DBGridLS.Columns[3].Width := 100;
DBGridLS.Columns[4].Width := 80;
DBGridLS.Columns[5].Width := 80;
DBGridLS.Columns[6].Width := 80;
DBGridLS.Columns[7].Width := 80;
DBGridLS.Columns[8].Width := 80;
end;
procedure TMessageDesignForm.ShowDataForYJ;
begin
adoqueryYJ.Close;
adoqueryYJ.SQL.Clear;
adoqueryYJ.SQL.Text:='select yjkhid as ID,yjkhxm as 姓名,yjkhzz as 住址,yjtel as 电话,yjckh as 车库号,yjcph as 车牌号,yjbkh as 补卡号,yjtype as 持卡类型,yjvalue as 费用 from 永久客户管理';
try
adoqueryYJ.Open;
except
showmessage('连接数据库失败,请重新启动应用程序!');
Application.Terminate;
exit;
end;
DBGridYJ.Columns[0].Width:=50;
DBGridYJ.Columns[1].Width := 80;
DBGridYJ.Columns[2].Width := 80;
DBGridYJ.Columns[3].Width := 80;
DBGridYJ.Columns[4].Width := 100;
DBGridYJ.Columns[5].Width := 80;
DBGridYJ.Columns[6].Width := 80;
DBGridYJ.Columns[7].Width := 80;
DBGridYJ.Columns[8].Width := 80;
end;
//*******************************************************************************
procedure TMessageDesignForm.SetState(State: TState);
begin
vState:=State;
case State of
vAdd,vModify:begin
//**********设置长期客户界面************
ButtonADD_CQ.Enabled:=false;
ButtonMODIFY_CQ.Enabled:=false;
ButtonDEL_CQ.Enabled:=false;
ButtonSAVE_CQ.Enabled:=true;
ButtonCANCEL_CQ.Enabled:=true;
EditID_CQ.ReadOnly:=false;
EditID_CQ.Color:=clWindow;
EditNAME_CQ.ReadOnly:=false;
EditNAME_CQ.Color:=clWindow;
EditADDRESS_CQ.ReadOnly:=false;
EditADDRESS_CQ.Color:=clWindow;
EditTEL_CQ.ReadOnly:=false;
EditTEL_CQ.Color:=clWindow;
EditCKH_CQ.ReadOnly:=false;
EditCKH_CQ.Color:=clWindow;
EditCPH_CQ.ReadOnly:=false;
EditCPH_CQ.Color:=clWindow;
EditBKH_CQ.ReadOnly:=false;
EditBKH_CQ.Color:=clWindow;
ComboboxCQ.Enabled:=true;
ComboboxCQ.Color:=clWindow;
EditCKQX_CQ.ReadOnly:=False;
EditCKQX_CQ.Color:=clWindow;
DateTimePicker1.Enabled:=true;
DateTimePicker1.Color:=clWindow;
DateTimePicker2.Enabled:=true;
DateTimePicker2.Color:=clWindow;
EditVALUE_CQ.ReadOnly:=True;
EditVALUE_CQ.Color:=$00D2D2D2;
//**************设置临时用户界面*******************
ButtonADD_LS.Enabled:=false;
ButtonMODIFY_LS.Enabled:=false;
ButtonDEL_LS.Enabled:=false;
ButtonSAVE_LS.Enabled:=true;
ButtonCANCEL_LS.Enabled:=true;
EditID_LS.ReadOnly:=false;
EditID_LS.Color:=clWindow;
EditNAME_LS.ReadOnly:=false;
EditNAME_LS.Color:=clWindow;
EditCKH_LS.ReadOnly:=false;
EditCKH_LS.Color:=clWindow;
EditCPH_LS.ReadOnly:=false;
EditCPH_LS.Color:=clWindow;
EditBKH_LS.ReadOnly:=false;
EditBKH_LS.Color:=clWindow;
ComboboxLS.Enabled:=true;
ComboboxLS.Color:=clWindow;
DateTimePicker3.Enabled:=true;
DateTimePicker3.Color:=clWindow;
DateTimePicker4.Enabled:=true;
DateTimePicker4.Color:=clWindow;
EditVALUE_LS.ReadOnly:=True;
EditVALUE_LS.Color:=$00D2D2D2;
//**************设置永久用户界面*******************
ButtonADD_YJ.Enabled:=false;
ButtonMODIFY_YJ.Enabled:=false;
ButtonDEL_YJ.Enabled:=false;
ButtonSAVE_YJ.Enabled:=true;
ButtonCANCEL_YJ.Enabled:=true;
EditID_YJ.ReadOnly:=false;
EditID_YJ.Color:=clWindow;
EditNAME_YJ.ReadOnly:=false;
EditNAME_YJ.Color:=clWindow;
EditADDRESS_YJ.ReadOnly:=false;
EditADDRESS_YJ.Color:=clWindow;
EditTEL_YJ.ReadOnly:=false;
EditTEL_YJ.Color:=clWindow;
EditCKH_YJ.ReadOnly:=false;
EditCKH_YJ.Color:=clWindow;
EditCPH_YJ.ReadOnly:=false;
EditCPH_YJ.Color:=clWindow;
EditBKH_YJ.ReadOnly:=false;
EditBKH_YJ.Color:=clWindow;
ComboboxYJ.Enabled:=true;
ComboboxYJ.Color:=clWindow;
EditVALUE_YJ.ReadOnly:=True;
EditVALUE_YJ.Color:=$00D2D2D2;
end;
vShow:begin
//**********长期客户界面*************
ButtonADD_CQ.Enabled:=true;
ButtonMODIFY_CQ.Enabled:=true;
ButtonDEL_CQ.Enabled:=true;
ButtonSAVE_CQ.Enabled:=false;
ButtonCANCEL_CQ.Enabled:=false;
DBGridCQ.Enabled:=true;
EditID_CQ.ReadOnly:=true;
EditID_CQ.Color:=$00D2D2D2;
EditNAME_CQ.ReadOnly:=true;
EditNAME_CQ.Color:=$00D2D2D2;
EditADDRESS_CQ.ReadOnly:=true;
EditADDRESS_CQ.Color:=$00D2D2D2;
EditTEL_CQ.ReadOnly:=true;
EditTEL_CQ.Color:=$00D2D2D2;
EditCKH_CQ.ReadOnly:=true;
EditCKH_CQ.Color:=$00D2D2D2;
EditCPH_CQ.ReadOnly:=true;
EditCPH_CQ.Color:=$00D2D2D2;
EditBKH_CQ.ReadOnly:=true;
EditBKH_CQ.Color:=$00D2D2D2;
ComboboxCQ.Enabled:=false;
ComboboxCQ.Color:= $00D2D2D2;
EditCKQX_CQ.ReadOnly := True;
EditCKQX_CQ.Color := $00D2D2D2;
DateTimePicker1.Enabled := False;
DateTimePicker1.Color := $00D2D2D2;
DateTimePicker2.Enabled := False;
DateTimePicker2.Color:= $00D2D2D2;
EditVALUE_CQ.ReadOnly := True;
EditVALUE_CQ.Color := $00D2D2D2;
//**********临时客户界面*************
ButtonADD_LS.Enabled:=true;
ButtonMODIFY_LS.Enabled:=true;
ButtonDEL_LS.Enabled:=true;
ButtonSAVE_LS.Enabled:=false;
ButtonCANCEL_LS.Enabled:=false;
EditID_LS.ReadOnly:=TRUE;
EditID_LS.Color:=$00D2D2D2;
EditNAME_LS.ReadOnly:=TRUE;
EditNAME_LS.Color:=$00D2D2D2;
EditCKH_LS.ReadOnly:=TRUE;
EditCKH_LS.Color:=$00D2D2D2;
EditCPH_LS.ReadOnly:=TRUE;
EditCPH_LS.Color:=$00D2D2D2;
EditBKH_LS.ReadOnly:=TRUE;
EditBKH_LS.Color:=$00D2D2D2;
ComboboxLS.Enabled:=FALSE;
ComboboxLS.Color:=$00D2D2D2;
DateTimePicker3.Enabled:=FALSE;
DateTimePicker3.Color:=$00D2D2D2;
DateTimePicker4.Enabled:=FALSE;
DateTimePicker4.Color:=$00D2D2D2;
EditVALUE_LS.ReadOnly:=True;
EditVALUE_LS.Color:=$00D2D2D2;
//**********永久客户界面*************
ButtonAdd_YJ.Enabled := True;
ButtonModify_YJ.Enabled := True;
ButtonDel_YJ.Enabled := True;
ButtonCancel_YJ.Enabled := False;
ButtonSave_YJ.Enabled := False;
DBGridYJ.Enabled := True;
EditID_YJ.ReadOnly := True;
EditID_YJ.Color := $00D2D2D2;
EditName_YJ.ReadOnly := True;
EditName_YJ.Color := $00D2D2D2;
EditAddress_YJ.ReadOnly := True;
EditAddress_YJ.Color := $00D2D2D2;
EditTEL_YJ.ReadOnly := True;
EditTEL_YJ.Color := $00D2D2D2;
EditCKH_YJ.ReadOnly := True;
EditCKH_YJ.Color := $00D2D2D2;
EditCPH_YJ.ReadOnly := True;
EditCPH_YJ.Color := $00D2D2D2;
EditBKH_YJ.ReadOnly := True;
EditBKH_YJ.Color := $00D2D2D2;
ComboboxYJ.Enabled := False;
ComboboxYJ.Color := $00D2D2D2;
EditVALUE_YJ.ReadOnly :=True;
EditVALUE_YJ.Color := $00D2D2D2;
end;
vMoneyOK:begin
//*********停车收费界面**************
EditMONEY_LS.ReadOnly:=true;
EditMONEY_LS.Color:= $00D2D2D2;
EditMONEY_CQ.ReadOnly:=true;
EditMONEY_CQ.Color:= $00D2D2D2;
EditMONEY_YJ.ReadOnly:=true;
EditMONEY_YJ.Color:= $00D2D2D2;
end;
vMoneyDESIGN:begin
//*********停车收费界面**************
EditMONEY_LS.ReadOnly:=false;
EditMONEY_LS.Color:=clWindow;
EditMONEY_CQ.ReadOnly:=false;
EditMONEY_CQ.Color:=clWindow;
EditMONEY_YJ.ReadOnly:=false;
EditMONEY_YJ.Color:=clWindow;
end;
end;
end;

[此贴子已经被作者于2007-4-26 9:38:42编辑过]

搜索更多相关主题的帖子: List bounds 数据库 index SetState 
2007-04-26 09:24
快速回复:List index out of bounds的错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033452 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved