当前位置: 代码迷 >> Web Service >> 请问Webservice返回dataset时的有关问题,多谢
  详细解决方案

请问Webservice返回dataset时的有关问题,多谢

热度:399   发布时间:2016-05-02 03:04:23.0
请教Webservice返回dataset时的问题,谢谢!
如果dataset.table中的数据只有一条时,可以正常返回,
如果dataset.table中的数据有多条时,就不能正常返回提示如下:
System.Data.ConstraintException:   Failed   to   enable   constraints.   One   or   more   rows   contain   values   violating   non-null,   unique,   or   foreign-key   constraints.
      at   System.Data.DataSet.FailedEnableConstraints()
      at   System.Data.DataSet.EnableConstraints()
      at   System.Data.DataSet.set_EnforceConstraints(Boolean   value)
      at   System.Data.Common.DataAdapter.Fill(DataTable[]   dataTables,   IDataReader   dataReader,   Int32   startRecord,   Int32   maxRecords)
      at   System.Data.Common.DbDataAdapter.FillInternal(DataSet   dataset,   DataTable[]   datatables,   Int32   startRecord,   Int32   maxRecords,   String   srcTable,   IDbCommand   command,   CommandBehavior   behavior)
      at   System.Data.Common.DbDataAdapter.Fill(DataTable[]   dataTables,   Int32   startRecord,   Int32   maxRecords,   IDbCommand   command,   CommandBehavior   behavior)
      at   System.Data.Common.DbDataAdapter.Fill(DataTable   dataTable)
      at   _800WebService1.GetDatabyid(String   VipCardID)   in   c:\Inetpub\wwwroot\800WebService\App_Code\800WebService1.cs:line   63



------解决方案--------------------
你的数据有问题:
违反了非空,唯一或者外键约束
------解决方案--------------------
Column 'code ' is constrained to be unique.
Value ' ' is already present.

你CODE列里是不是有空值阿?
  相关解决方案