次のストアド プロシージャが .net c# で問題を引き起こすのはなぜですか。基本的には、画面上の利益のレポートの性質のために読み取り専用で使用されます。私のアダプターの塗りつぶしでも同じで、例外がスローされます
手順 :
public virtual EmployeeBenefitDataset GetBenefitsRecords(int id)
{
try
{
EmployeeBenefitDataset ds = new EmployeeBenefitDataset();
using (BenefitTableAdapter adpt = new BenefitTableAdapter())
{
adpt.Connection.ConnectionString = DataAccessLogicHelper.PamsConnectionString;
adpt.Fill(ds.BenefitRecords, id, 4, null,null);
}
return ds;
}
catch (Exception ex)
{
Logger.ErrorEntry(ex);
throw ex;
}
ストアドプロシージャ
GO
/****** Object: StoredProcedure [dbo].[hms_GetBenefitRecordsDetails] Script Date: 09/09/2013 14:09:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[hms_GetBenefitRecordsDetails]
(
@empno int,
@type int,
@stardate datetime,
@enddate datetime
)
AS
SET NOCOUNT ON;
IF NOT @stardate IS NULL
begin
SELECT benefit.emp_no, benefit.record_id, benefit.contract_id, benefit.career_id, benefit.date_from, benefit.date_to, benefit.benefit_type, benefit.monthly_value,
benefit.benefit_provider, benefit.level_of_cover, benefit.previous_monthly_cost, benefit.benefit_change_details, benefit.current_benefit, benefit.notes,
benefit.level_description, benefit.monthly_annual, benefit.cover_level, benefit.qualifying_reason, benefit_cover_level.desc_ AS benefitcoverdescription,
benefit_provider.desc_ AS benefitproviderdescription,benefit_type.desc_ as benefittypedescription ,employee.benefit_annual_amount,employee.benefit_salary_option,employee.benefit_value
FROM benefit INNER JOIN
benefit_cover_level ON benefit.cover_level = benefit_cover_level.code INNER JOIN
benefit_provider ON benefit.benefit_provider = benefit_provider.code INNER JOIN
benefit_type ON benefit.benefit_type = benefit_type.code
INNER JOIN employee on benefit.emp_no = @empno
where benefit.emp_no= @empno or employee.emp_no= benefit.emp_no
and benefit.benefit_type = @type
end
else
begin
SELECT benefit.emp_no, benefit.record_id, benefit.contract_id, benefit.career_id, benefit.date_from, benefit.date_to, benefit.benefit_type, benefit.monthly_value,
benefit.benefit_provider, benefit.level_of_cover, benefit.previous_monthly_cost, benefit.benefit_change_details, benefit.current_benefit, benefit.notes,
benefit.level_description, benefit.monthly_annual, benefit.cover_level, benefit.qualifying_reason, benefit_cover_level.desc_ AS benefitcoverdescription,
benefit_provider.desc_ AS benefitproviderdescription,benefit_type.desc_ as benefittypedescription ,employee.benefit_annual_amount,employee.benefit_salary_option,employee.benefit_value
FROM benefit INNER JOIN
benefit_cover_level ON benefit.cover_level = benefit_cover_level.code INNER JOIN
benefit_provider ON benefit.benefit_provider = benefit_provider.code INNER JOIN
benefit_type ON benefit.benefit_type = benefit_type.code
INNER JOIN employee on benefit.emp_no = @empno
where benefit.emp_no= @empno and employee.emp_no= benefit.emp_no
end
IF NOT @stardate IS NULL
begin
SELECT benefit.emp_no, benefit.record_id, benefit.contract_id, benefit.career_id, benefit.date_from, benefit.date_to, benefit.benefit_type, benefit.monthly_value,
benefit.benefit_provider, benefit.level_of_cover, benefit.previous_monthly_cost, benefit.benefit_change_details, benefit.current_benefit, benefit.notes,
benefit.level_description, benefit.monthly_annual, benefit.cover_level, benefit.qualifying_reason, benefit_cover_level.desc_ AS benefitcoverdescription,
benefit_provider.desc_ AS benefitproviderdescription,benefit_type.desc_ as benefittypedescription ,employee.benefit_annual_amount,employee.benefit_salary_option,employee.benefit_value
FROM benefit INNER JOIN
benefit_cover_level ON benefit.cover_level = benefit_cover_level.code INNER JOIN
benefit_provider ON benefit.benefit_provider = benefit_provider.code INNER JOIN
benefit_type ON benefit.benefit_type = benefit_type.code
INNER JOIN employee on benefit.emp_no = @empno
where benefit.emp_no= @empno and employee.emp_no= benefit.emp_no and
benefit.benefit_type = @type and
benefit.date_from >= @stardate and benefit.date_to <= @enddate
end