procedure TForm1.Button1Click(Sender: TObject);
begin
adodataset1.Close;
adostoredproc2.ExecProc;AdoQuery1.close;
AdoQuery1.SQL.Clear;
AdoQuery1.sql.add('select * from ryxx');
adoquery1.First;
//while not eof ////如果不是表的最后一行(你要的问题的答案!)//if AdoQuery1.eof then
// ShowMessage('已经到了表的末尾');
if trim(edit1.text)='' then
begin
while not eof do
begin
with adoStoredproc1 do
begin
Parameters.ParamByName('@rfkh').Value:='0000000001';
//adoquery1.FieldByName('rfkh').Value;
ExecProc;
end;
adoquery1.Next;//指向下一条记录
end;
end
else
begin
with adoStoredproc1 do
begin
Parameters.ParamByName('@rfkh').Value:=trim(edit1.text);
ExecProc;
end;
end;
AdoQuery1.close;
adodataset1.CommandText:='select * from zmph';
adodataset1.Close;
adodataset1.Open;
adostoredproc2.ExecProc;end;
错误提示:ADOQUERY1:cannot perform this operation on a closed dataset
begin
adodataset1.Close;
adostoredproc2.ExecProc;AdoQuery1.close;
AdoQuery1.SQL.Clear;
AdoQuery1.sql.add('select * from ryxx');
adoquery1.First;
//while not eof ////如果不是表的最后一行(你要的问题的答案!)//if AdoQuery1.eof then
// ShowMessage('已经到了表的末尾');
if trim(edit1.text)='' then
begin
while not eof do
begin
with adoStoredproc1 do
begin
Parameters.ParamByName('@rfkh').Value:='0000000001';
//adoquery1.FieldByName('rfkh').Value;
ExecProc;
end;
adoquery1.Next;//指向下一条记录
end;
end
else
begin
with adoStoredproc1 do
begin
Parameters.ParamByName('@rfkh').Value:=trim(edit1.text);
ExecProc;
end;
end;
AdoQuery1.close;
adodataset1.CommandText:='select * from zmph';
adodataset1.Close;
adodataset1.Open;
adostoredproc2.ExecProc;end;
错误提示:ADOQUERY1:cannot perform this operation on a closed dataset
-------
加一个
AdoQuery1.Open
-------
adoquery1.First;
ADOQuery1.Open; //少了这句
adoquery1.First;
AdoQuery1.SQL.Clear;
AdoQuery1.sql.add('select * from ryxx');
后加个
AdoQuery1.Open;
楼主的
while not eof do
是不是要改为
while not AdoQuery1.eof do 呢?