执行存储过程,第一遍可以,第二遍出错
系统提示
---------------------------
Debugger Exception Notification
---------------------------
Project Re.exe raised exception class EAccessViolation with message 'Access violation at address 4DD419E8 in module 'msado15.dll'. Read of address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
SP_Percent.ExecProc;//第二遍,在这个地方就出错
- Delphi(Pascal) code
procedure TFrm_RP.Btn_AppPercentClick(Sender: TObject);var Str_Path,Str_RPFile:string; Str_DeptName:string;begin inherited; try try with DM do begin SP_Percent.Close; //通过存储过程来调用 SP_Percent.ProcedureName :='P_AppointPercent'; SP_Percent.Parameters.Clear; SP_Percent.Parameters.Refresh; SP_Percent.Parameters.ParamByName('@S_BeginTime').Value := DTP_Begin.Date; SP_Percent.Parameters.ParamByName('@S_EndTime').Value := DTP_End.Date; SP_Percent.Parameters.ParamByName('@DeptID').Value := '25'; SP_Percent.Parameters.ParamByName('@AllDept').Value := 1; SP_Percent.Parameters.ParamByName('@CountApp').Value := -1; SP_Percent.Parameters.ParamByName('@CountAppYse').Value := -1; SP_Percent.Parameters.ParamByName('@CountAppNo').Value := -1; SP_Percent.ExecProc;//第二遍,在这个地方就出错 Str_Path:= ExtractFilePath( Application.ExeName ); Str_RPFile := Str_Path + 'rp\AppPercent.rmf'; RMDBDataSet_DM.DataSet := SP_Percent; RMReport_DM.LoadFromFile(Str_RPFile); RMReport_DM.PrepareReport(); RMReport_DM.ShowReport; end; except on E:Exception do begin Write_LogErr(FinalUnit+'0004:打印赴约图表',IntToStr(E.HelpContext)+':'+E.Message,''); end; end;//end except finally DM.SP_Percent.Close; end;//end finallyend;[解决办法]
去掉
SP_Percent.Parameters.Clear;
SP_Percent.Parameters.Refresh;
有你的存程是做某些作是返回集,返回集的一般用Active:=True;,做似update,insert作就用ExecProc
[解决办法]
掉个简单点的存储过程,试试,代码貌似无问题