Delphi 使用TADOStoredProc执行存储过程
if MessageDlg('是否要删除信息?',mtInformation,mbOKCancel,0) = mrOk then
begin
with adoSp1 do // adoSp1是 TADOStoredProc类型的控件
begin
Close;
ProcedureName := 'BL_HV_DeleteCustomerInfo'; //'BL_HV_DeleteCustomerInfo' 存储过程名称
Parameters.Refresh;
Parameters.ParamByName('@CustomerID').Value := Trim(edtCustomerID.Text);
Parameters.ParamByName('@ErrorCode').Value := -1;
Parameters.ParamByName('@ErrorMessage').Value := '0';
ExecProc;
ErrorCodeStr := Parameters.ParamByName('@ErrorCode').Value;
if ErrorCodeStr <> '0' then
begin
if ErrorCodeStr ='2' then
begin
if edtCustomerName.CanFocus then
edtCustomerName.SetFocus;
ShowMessage(Parameters.ParamByName('@ErrorMessage').Value);
end;
end;
if dbgrdhCustomer.CanFocus then
dbgrdhCustomer.SetFocus;
end;
end;
end;