为什么我调用存储工程时,老是出现数据集没有打开:我时这样写的
-- 码单继续查询最大码单号以及相应的详细信息CREATE PROCEDURE InyardNo_proc
@indate datetime,
@productid char(4),
@gradeid char(4),
@batchno varchar(20),
@packagetype char(4),
@departid char(4),
@package char(1),
@workno char(4),
@isback char(1),
@machineid varchar(10) output,
@boxno int output,
@boxweight dec(2) output,
@unitweight dec(3) output,
@unitnum int output,
@weightgross dec(2) output,
@weightnet dec(2)output
as
select @machineid =machineid,@boxno=boxno,@boxweight = boxweight,@unitweight = unitweight,@unitnum = unitnumber,@weightgross = weightgross,@weightnet = weightnet
from p_insub
where inyardno = (select max(inyardno)
from p_inmain
where (productid =@productid or @productid = '') and
(gradeid = @gradeid or @gradeid = '')and
(departid = @departid or @departid = '') and
(packagetypeid = @packagetype or @packagetype = '') and
(package = @package or @package= '') and
batchno = @batchno and
workno = @workno and
(send = '0' or send = '')and
indate =@indate)
GO、、调用如下
DM.ADOStoredProc1.Close;
DM.ADOStoredProc1.ProcedureName:='inyardno_proc';
DM.ADOStoredProc1.Parameters.Refresh;
DM.ADOStoredProc1.Parameters.ParamValues['@productid']:=productid;
DM.ADOStoredProc1.Parameters.ParamValues['@gradeid']:= gradeid;
DM.ADOStoredProc1.Parameters.ParamValues['@batchno']:= batchno;
DM.ADOStoredProc1.Parameters.ParamValues['@packagetype']:= packagetype;
DM.ADOStoredProc1.Parameters.ParamValues['@departid']:= departmentid;
DM.ADOStoredProc1.Parameters.ParamValues['@workno']:= workno;
DM.ADOStoredProc1.Parameters.ParamValues['@indate']:= indate;
DM.ADOStoredProc1.Parameters.ParamValues['@isback']:=isback;
DM.ADOStoredProc1.ExecProc; if DM.ADOStoredProc1.RecordCount<>0 then
begin
i :=1;
DM.ADOStoredProc1.First;
while not DM.ADOStoredProc1.Eof do
begin
frmcollect.StringGrid1.Cells[0,i]:= inttostr(i);
frmcollect.StringGrid1.Cells[1,i] :=DM.ADOStoredProc1.FieldValues['machineid'];
frmcollect.StringGrid1.Cells[2,i]:=inttostr(DM.ADOStoredProc1.FieldValues['boxno']);
frmcollect.StringGrid1.Cells[3,i]:=floattostr(DM.ADOStoredProc1.FieldValues['boxweight']);
frmcollect.StringGrid1.Cells[4,i]:=inttostr(DM.ADOStoredProc1.FieldValues['unitnum']);
frmcollect.StringGrid1.Cells[5,i]:=floattostr(DM.ADOStoredProc1.FieldValues['unitweight']);
frmcollect.StringGrid1.Cells[6,i]:=floattostr(DM.ADOStoredProc1.FieldValues['weightgross']);
frmcollect.StringGrid1.Cells[7,i]:=floattostr(DM.ADOStoredProc1.FieldValues['weightnet']);
i := i + 1;
end;
-- 码单继续查询最大码单号以及相应的详细信息CREATE PROCEDURE InyardNo_proc
@indate datetime,
@productid char(4),
@gradeid char(4),
@batchno varchar(20),
@packagetype char(4),
@departid char(4),
@package char(1),
@workno char(4),
@isback char(1),
@machineid varchar(10) output,
@boxno int output,
@boxweight dec(2) output,
@unitweight dec(3) output,
@unitnum int output,
@weightgross dec(2) output,
@weightnet dec(2)output
as
select @machineid =machineid,@boxno=boxno,@boxweight = boxweight,@unitweight = unitweight,@unitnum = unitnumber,@weightgross = weightgross,@weightnet = weightnet
from p_insub
where inyardno = (select max(inyardno)
from p_inmain
where (productid =@productid or @productid = '') and
(gradeid = @gradeid or @gradeid = '')and
(departid = @departid or @departid = '') and
(packagetypeid = @packagetype or @packagetype = '') and
(package = @package or @package= '') and
batchno = @batchno and
workno = @workno and
(send = '0' or send = '')and
indate =@indate)
GO、、调用如下
DM.ADOStoredProc1.Close;
DM.ADOStoredProc1.ProcedureName:='inyardno_proc';
DM.ADOStoredProc1.Parameters.Refresh;
DM.ADOStoredProc1.Parameters.ParamValues['@productid']:=productid;
DM.ADOStoredProc1.Parameters.ParamValues['@gradeid']:= gradeid;
DM.ADOStoredProc1.Parameters.ParamValues['@batchno']:= batchno;
DM.ADOStoredProc1.Parameters.ParamValues['@packagetype']:= packagetype;
DM.ADOStoredProc1.Parameters.ParamValues['@departid']:= departmentid;
DM.ADOStoredProc1.Parameters.ParamValues['@workno']:= workno;
DM.ADOStoredProc1.Parameters.ParamValues['@indate']:= indate;
DM.ADOStoredProc1.Parameters.ParamValues['@isback']:=isback;
DM.ADOStoredProc1.ExecProc; if DM.ADOStoredProc1.RecordCount<>0 then
begin
i :=1;
DM.ADOStoredProc1.First;
while not DM.ADOStoredProc1.Eof do
begin
frmcollect.StringGrid1.Cells[0,i]:= inttostr(i);
frmcollect.StringGrid1.Cells[1,i] :=DM.ADOStoredProc1.FieldValues['machineid'];
frmcollect.StringGrid1.Cells[2,i]:=inttostr(DM.ADOStoredProc1.FieldValues['boxno']);
frmcollect.StringGrid1.Cells[3,i]:=floattostr(DM.ADOStoredProc1.FieldValues['boxweight']);
frmcollect.StringGrid1.Cells[4,i]:=inttostr(DM.ADOStoredProc1.FieldValues['unitnum']);
frmcollect.StringGrid1.Cells[5,i]:=floattostr(DM.ADOStoredProc1.FieldValues['unitweight']);
frmcollect.StringGrid1.Cells[6,i]:=floattostr(DM.ADOStoredProc1.FieldValues['weightgross']);
frmcollect.StringGrid1.Cells[7,i]:=floattostr(DM.ADOStoredProc1.FieldValues['weightnet']);
i := i + 1;
end;
if DM.ADOStoredProc1.RecordCount<>0 then //在这里你不应该只判断ADOStoredProc1.RecordCount<>0,如果数据集没有返回数据集时,recordcount可能为-1,我遇到过这种事情,你应该判断 ADOStoredProc1.RecordCount>0
.......if DM.ADOStoredProc1.RecordCount>0 then
begin
i :=1;
DM.ADOStoredProc1.First;
while not DM.ADOStoredProc1.Eof do
begin