Delphi 使用TADOStoredProc执行存储过程

来源:互联网 发布:淘宝网是b2c还是c2c 编辑:程序博客网 时间:2024/04/30 13:47

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;

原创粉丝点击