获取错误:
无法启用约束。一或多个行包含值 违反非空,唯一或外键约束
我的代码中有dataTable 并返回32000条记录的
protected DataTable RunCommandToDataTable(string commandText, CommandType commandType, params SqlParameter[] parameters)
{
var dt = new DataTable();
using (var command = UnitOfWork.Database.Connection.CreateCommand())
{
try
{
UnitOfWork.Database.Connection.Open();
command.CommandText = commandText;
command.CommandTimeout = command.Connection.ConnectionTimeout;
command.CommandType = commandType;
command.Parameters.AddRange(parameters.ToArray());
using (IDataReader reader = command.ExecuteReader())
{
--load Data this is Erorr
dt.Load(reader, LoadOption.OverwriteChanges);
--load Data this is Erorr
}
}
finally
{
UnitOfWork.Database.Connection.Close();
command.Parameters.Clear();
}
}
return dt;
}