我的程序中原来有这样一段,用于将内容保存到sheet_product表中.
ADOStoredProc4的ProcedureName属性赋值为find_sheet,这是我在数据库中原有的存储过程!
//保存SQL数据
if ADOConnection2.Connected then begin
ADOStoredProc4.active:=false;
ADOStoredProc4.Parameters.ParamByName('@sheet_id').Value:=label3d54.Caption;
ADOStoredProc4.active:=true;
if ADOStoredProc4.recordcount=0 then begin
sh_a_time:=now;
pbar1.Visible:=true;
//保存sheet_product
with ADOStoredProc4 do begin
Append;
FieldByName('sheetid').Value:=label3d54.Caption;
FieldByName('sheeterid').Value:=edit2.Text;
FieldByName('shift_q').Value:=copy(combobox1.Text,1,1);
FieldByName('date_q').Value:=copy(combobox5.Text,1,4)+'-'+copy(combobox6.Text,1,2)+'-'+copy(combobox7. Text,1,2)+formatdatetime(' hh:nn:ss',now);
FieldByName('width').Value:=strtoint(floatedit1.Text);
FieldByName('length').Value:=strtoint(floatedit2.Text);
FieldByName('grade').Value:=copy(combobox2.Text,1,1);
FieldByName('ream').Value:=floatedit3.Value;
FieldByName('reams').Value:=floatedit4.Value;
FieldByName('calc_w').Value:=strtofloat(edit6.Text);
FieldByName('inspector').Value:=edit5.Text;
Post;
end;
现在我又新添加了下面一段内容: 目的是想将上面的内容再保存一次,保存到另外一个新建的lsheet_product表中去.
新增添的ADOStoredProc7的ProcedureName属性赋值为find_lsheet,这是我在数据库中新建的一个存储过程!
//chenjie新加下面23行,作用为了保存lsheet_product
if ADOConnection2.Connected then begin
ADOStoredProc7.active:=false;
ADOStoredProc7.Parameters.ParamByName('@lsheet_id').Value:=label3d54.Caption;
ADOStoredProc7.active:=true;
//if ADOStoredProc7.recordcount=0 then begin
// sh_a_time:=now;
// pbar1.Visible:=true;
with ADOStoredProc7 do begin
Append;
FieldByName('lsheetid').Value:=label3d54.Caption;
FieldByName('lsheeterid').Value:=edit2.Text;
FieldByName('lshift_q').Value:=copy(combobox1.Text,1,1); FieldByName('ldate_q').Value:=copy(combobox5.Text,1,4)+'-'+copy(combobox6.Text,1,2)+'-'+copy(combobox7. Text,1,2)+formatdatetime(' hh:nn:ss',now);
FieldByName('lwidth').Value:=strtoint(floatedit1.Text);
FieldByName('llength').Value:=strtoint(floatedit2.Text);
FieldByName('lgrade').Value:=copy(combobox2.Text,1,1);
FieldByName('lream').Value:=floatedit3.Value;
FieldByName('lreams').Value:=floatedit4.Value;
FieldByName('lcalc_w').Value:=strtofloat(edit6.Text);
FieldByName('linspector').Value:=edit5.Text;
Post;
end;
两个存储过程的编写为:
CREATE PROCEDURE [dbo].[find_sheetid] @sheet_id varchar(15) AS
Select * from sheet_product
where sheetid=@sheet_id
GO
CREATE PROCEDURE [dbo].[find_lsheetid] @lsheet_id varchar(15) AS
Select * from lsheet_product
where lsheetid=@lsheet_id
GO
但是调试过程中总是报以下错误:
project sheet.exe raised exception class edatabaseerror with message 'adostoredproc7:cannot perform this operation on a closed dataset'. process stopped. use step or run to continue.
希望高手可以指教一下!!~~