本文介绍了如何解决“无法启用约束”的问题。一行或多行包含违反非空,唯一或外键约束的值。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调用该函数时

when i call the function

public DataTable GetAllBySurSurveyId(Int64 surSurveyId)
        {
            DataTable dtSurSurveyTeam = null;
            try
            {
                dtSurSurveyTeam = Adapter.sp_4_15_GetAllBySurSurveyId(surSurveyId);
            }
            catch (Exception ex)
            {
                ErrorWriter.WriteError(ex, "FunctionName --> GetDataTable", RequestPage);
            }
            return dtSurSurveyTeam;
        }





上述错误来了。我用storeprocedure绑定了quary,storeprocedure显示了数据。



storeprocedure:





the above error came. i have binded the quary with storeprocedure and the storeprocedure is showing the data.

storeprocedure :

ALTER PROCEDURE [dbo].[sp_4_15_GetAllBySurSurveyId] 
	-- Add the parameters for the stored procedure here
	@surSurveyId AS nvarchar(MAX)
AS
BEGIN

DECLARE @Sql1 AS NVARCHAR(MAX)

SET @Sql1 =
'SELECT        T.SurSurveyTeamId, O.OfficeName, T.SurveyTeamName, T.TeamDescription,
                             (SELECT        COUNT(SurSurveyTeamMemberId) AS TotalMembers
                               FROM            SurRelationSurveyTeamToTeamMember AS RTM
                               WHERE        (SurSurveyTeamId = R.SurSurveyTeamId)) AS TotalMembers
FROM            SurRelationSurveyToSurveyTeam AS R LEFT OUTER JOIN
                         SurSurveyTeam AS T ON T.SurSurveyTeamId = R.SurSurveyTeamId LEFT OUTER JOIN
                         UsmOffice AS O ON O.UsmOfficeId = T.UsmOfficeId
WHERE        (R.SurSurveyId = '+@surSurveyId+')'
 
EXECUTE (@Sql1)	
END

推荐答案


这篇关于如何解决“无法启用约束”的问题。一行或多行包含违反非空,唯一或外键约束的值。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 19:55