M
monster112115
Unregistered / Unconfirmed
GUEST, unregistred user!
急,请问各位大侠下面这段代码到底有什么错误???
我编译时,老是出现list index out of bounds(0)这样的出错提示
procedure TForm3.FlatButton22Click(Sender: TObject);
var
ssql,qssj,jzsj:string;
begin
qssj:=datetostr(datetimepicker1.Date);
jzsj:=datetostr(datetimepicker2.Date);
if (not checkbox1.checked) and (not checkbox2.checked) and (not checkbox3.checked) and
(not checkbox4.checked) and (not checkbox5.checked) and (not checkbox6.checked) and
(not checkbox7.checked) and (not checkbox8.checked) then
MessageDlg('对不起,如果需查询,请先选择查询条件!',mtinformation,[mbok],0)
else
begin
if checkbox1.Checked then
begin
ssql:='where 案件类别=:ajnbp';
end;
if checkbox4.Checked then
begin
ssql:=ssql+''+'and'+''+'作案手段=:zasdp';
end;
if checkbox5.Checked then
begin
ssql:=ssql+''+'and'+''+'作案工具=:zagjp';
end;
if checkbox6.Checked then
begin
ssql:=ssql+''+'and'+''+'主犯姓名=:zfxmp';
end;
if checkbox7.Checked and checkbox8.Checked then
ssql:=ssql+''+'and'+''+'发案时间 <=:jzsjp'+''+'and'+''+'发案时间 >=:qssjp'
else
begin
if checkbox7.Checked then
ssql:=ssql+''+'and'+''+'发案时间 >=:qssjp';
if checkbox8.checked then
ssql:=ssql+''+'and'+''+'发案时间 <=:jzsjp';
end;
end;
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.sql.Add('select 编号,案件名称');
adoquery2.sql.Add('from 案件');
adoquery2.sql.add(ssql);
adoquery2.Parameters[0].Value:=dbcombobox1.items[dbcombobox1.itemindex];
adoquery2.Parameters[3].Value:=dbcombobox2.Items[dbcombobox2.ItemIndex];
adoquery2.Parameters[4].Value:=dbcombobox3.Items[dbcombobox3.ItemIndex];
adoquery2.Parameters[5].Value:=edit1.text;
adoquery2.Parameters[6].Value:=qssj;
adoquery2.Parameters[7].Value:=jzsj;
adoquery2.prepared ;
adoquery2.Open;
if AdoQuery2.RecordCount=0 then
MessageDlg('对不起,没有您所要查找的资料,请重新选择查询条件!',
mtinformation,[mbok],0);
end;
我编译时,老是出现list index out of bounds(0)这样的出错提示
procedure TForm3.FlatButton22Click(Sender: TObject);
var
ssql,qssj,jzsj:string;
begin
qssj:=datetostr(datetimepicker1.Date);
jzsj:=datetostr(datetimepicker2.Date);
if (not checkbox1.checked) and (not checkbox2.checked) and (not checkbox3.checked) and
(not checkbox4.checked) and (not checkbox5.checked) and (not checkbox6.checked) and
(not checkbox7.checked) and (not checkbox8.checked) then
MessageDlg('对不起,如果需查询,请先选择查询条件!',mtinformation,[mbok],0)
else
begin
if checkbox1.Checked then
begin
ssql:='where 案件类别=:ajnbp';
end;
if checkbox4.Checked then
begin
ssql:=ssql+''+'and'+''+'作案手段=:zasdp';
end;
if checkbox5.Checked then
begin
ssql:=ssql+''+'and'+''+'作案工具=:zagjp';
end;
if checkbox6.Checked then
begin
ssql:=ssql+''+'and'+''+'主犯姓名=:zfxmp';
end;
if checkbox7.Checked and checkbox8.Checked then
ssql:=ssql+''+'and'+''+'发案时间 <=:jzsjp'+''+'and'+''+'发案时间 >=:qssjp'
else
begin
if checkbox7.Checked then
ssql:=ssql+''+'and'+''+'发案时间 >=:qssjp';
if checkbox8.checked then
ssql:=ssql+''+'and'+''+'发案时间 <=:jzsjp';
end;
end;
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.sql.Add('select 编号,案件名称');
adoquery2.sql.Add('from 案件');
adoquery2.sql.add(ssql);
adoquery2.Parameters[0].Value:=dbcombobox1.items[dbcombobox1.itemindex];
adoquery2.Parameters[3].Value:=dbcombobox2.Items[dbcombobox2.ItemIndex];
adoquery2.Parameters[4].Value:=dbcombobox3.Items[dbcombobox3.ItemIndex];
adoquery2.Parameters[5].Value:=edit1.text;
adoquery2.Parameters[6].Value:=qssj;
adoquery2.Parameters[7].Value:=jzsj;
adoquery2.prepared ;
adoquery2.Open;
if AdoQuery2.RecordCount=0 then
MessageDlg('对不起,没有您所要查找的资料,请重新选择查询条件!',
mtinformation,[mbok],0);
end;