H
huayf
Unregistered / Unconfirmed
GUEST, unregistred user!
with ADOQuery3 do begin
SQL.Text :='select count(ques) as sum from quest where name='''+Edit1.Text+'''';
Prepared;
Open;
end;
q :=ADOQuery3.FieldByName('sum').Value
with ADOQuery1 do begin
SQL.Text :='select ques from quest where name='''+Edit1.Text+'''';
Prepared;
Open;
end;
//--------------------读问题选项并赋值给数组-----------------------------------
with ADOQuery2 do begin
SQL.Text :='select count(chck) as sum from answ where name='''+Edit1.Text +''' and qst='''+ADOQuery1.FieldByName('ques').Value+'''';
Prepared;
Open;
end;
n :=ADOQuery2.FieldByName('sum').Value;
SetLength (MyCheck,q,n)
//确定二维数组的长度
//-----------问题出在以下这段代码------------------
for H := 0 to q-1 do begin
for J := 0 to n-1 do begin
with ADOQuery2 do begin
SQL.Text :='select chck from answ where name='''+Edit1.text+''' and qst='''+ADOQuery1.FieldByName('ques').Value+'''';
Prepared;
Open;
while not EOF do begin
MyCheck[H,J] := FieldByName('chck').Value
Next;
end;
end;
end;
读表给二维数组赋值,发现循环不对,二维数组种新的数据覆盖了前面的数据
SQL.Text :='select count(ques) as sum from quest where name='''+Edit1.Text+'''';
Prepared;
Open;
end;
q :=ADOQuery3.FieldByName('sum').Value
with ADOQuery1 do begin
SQL.Text :='select ques from quest where name='''+Edit1.Text+'''';
Prepared;
Open;
end;
//--------------------读问题选项并赋值给数组-----------------------------------
with ADOQuery2 do begin
SQL.Text :='select count(chck) as sum from answ where name='''+Edit1.Text +''' and qst='''+ADOQuery1.FieldByName('ques').Value+'''';
Prepared;
Open;
end;
n :=ADOQuery2.FieldByName('sum').Value;
SetLength (MyCheck,q,n)
//确定二维数组的长度
//-----------问题出在以下这段代码------------------
for H := 0 to q-1 do begin
for J := 0 to n-1 do begin
with ADOQuery2 do begin
SQL.Text :='select chck from answ where name='''+Edit1.text+''' and qst='''+ADOQuery1.FieldByName('ques').Value+'''';
Prepared;
Open;
while not EOF do begin
MyCheck[H,J] := FieldByName('chck').Value
Next;
end;
end;
end;
读表给二维数组赋值,发现循环不对,二维数组种新的数据覆盖了前面的数据