调查问卷添加问题提示插入重复键错误
作者:动易软件
来源:本站原创
点击数: 次
发布时间:2018年03月02日
问题描述:提交问卷调查提示插入重复键错误:
解决方法:该项错误查到客户没有开启pe_surveyvote表ID列开启自增,如图所示。(操作前请先备份好数据库)
等到客户开启自增后会报如图所示错误
然后去看PR_Survey_SurveyVote_Add存储过程,修改成如下代码
GO
/****** Object: StoredProcedure [dbo].[PR_Survey_SurveyVote_Add] Script Date: 2018/3/2 15:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[PR_Survey_SurveyVote_Add]
(
@Id INT ,
@SurveyId INT ,
@QuestionId INT ,
@OptionCount INT
)
AS
DECLARE @option INT
SET @option = 0
WHILE ( @option < @OptionCount )
BEGIN
INSERT INTO [PE_SurveyVote]
( SurveyId, QuestionId, OptionId )
VALUES ( @SurveyId, @QuestionId, @option )
SET @option = @option + 1
END