请教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列里是不是有空值阿?