Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将错误获取为插入失败,因为以下集合选项的设置不正确_C#_Sql_Sql Server - Fatal编程技术网

C# 将错误获取为插入失败,因为以下集合选项的设置不正确

C# 将错误获取为插入失败,因为以下集合选项的设置不正确,c#,sql,sql-server,C#,Sql,Sql Server,我的代码将数据作为XML从C#code behind(其在本地运行良好)插入SQL Server 2008,但在SQL Server 2005的远程实例上,它引发了以下异常。请帮忙 创建过程SqAnswersInsert@AnswerID INT OUTPUT, @ClientID INT=NULL, @VGBID INT=NULL, @CreatedOn DATETIME=NULL, @XmlOptions XML=NULL作为开始 SET ARITHABORT ON

我的代码将数据作为XML从C#code behind(其在本地运行良好)插入SQL Server 2008,但在SQL Server 2005的远程实例上,它引发了以下异常。请帮忙

创建过程SqAnswersInsert@AnswerID INT OUTPUT,
@ClientID INT=NULL,
@VGBID INT=NULL,
@CreatedOn DATETIME=NULL,
@XmlOptions XML=NULL作为开始

  SET ARITHABORT ON            
  INSERT SqAnswers        
         (ClientID,        
          VGBID,        
          [CreatedOn])        
  VALUES (@ClientID,        
          @VGBID,        
          @CreatedOn)        

  SET @AnswerID=Scope_identity()        

  INSERT INTO SqAnswerOptions        
              (AnswerID,        
               QuestionOptionID)        

  SELECT @AnswerID,A.B.value('QuestionOptionID[1]', 'INT') AS QuestionOptionID        
  --A.B.value('QuestionOptions/QuestionOptionID', 'INT') as QuestionOptionID          
  FROM   @XmlOptions.nodes('/QuestionOptions/Option') A(B)        
  SET ARITHABORT OFF               END
插入失败,因为以下集合选项的设置不正确:“ARITHABORT”。验证集合选项是否正确用于索引视图和/或计算列上的索引和/或筛选索引和/或查询通知和/或XML数据类型方法和/或空间索引操作


当数据库中有索引视图时,在执行任何其他SQL命令之前,必须在每次连接到Microsoft SQL Server时执行SQL命令
将ARITHABORT设置为ON

可以通过从数据库视图中删除索引来消除此错误

在查询执行期间发生溢出或被零除错误时终止查询

来自Technet

1. If SET ARITHABORT is ON and SET ANSI WARNINGS is ON, these error
    conditions cause the query to terminate.
 2. If SET ARITHABORT is ON and SET ANSI WARNINGS is OFF, these error
    conditions cause the batch to terminate. If the errors occur in a
    transaction, the transaction is rolled back. If SET ARITHABORT is
    OFF and one of these errors occurs, a warning message is displayed,
    and NULL is assigned to the result of the arithmetic operation.
 3. If SET ARITHABORT is OFF and SET ANSI WARNINGS is OFF and one of
    these errors occurs, a warning message is displayed, and NULL is
    assigned to the result of the arithmetic operation.

你能发布你的查询吗???@NagarajS请现在检查查询谢谢Vignesh,我的问题已经解决了,但是当我没有使用算术运算或任何索引视图时,为什么我会得到这个结果error@AjaySuwalka您可能有登录会话
SET 
ANSI_NULLS, 
QUOTED_IDENTIFIER, 
CONCAT_NULL_YIELDS_NULL, 
ANSI_WARNINGS, 
ANSI_PADDING 
ON;

INSERT INTO TABLE(@CLOUMNS) VALUES(@VALUE)