I have this method:
public static DataTable ExecuteDataTable(IDbConnection connection, string cmdText)
{
IDbCommand command = connection.CreateCommand();
command.CommandText = cmdText;
command.CommandType = CommandType.Text;
IDataReader reader = command.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
return dt;
}
When i execute the query select * from information_schema.Tables against a connection of type SQLConnection it all works.
However, when I try to run it against a connection of type SqlCEConnection the line dt.Load(reader) raises an exception:
System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
DataTableto see what caused aConstraintException. Set a breakpoint right at the linedt.Load(reader);. User a Quick-Watch Window to execute this line. Then you can get all rows with errors withdt.GetErrors(). Then you can look into each returned DataRow'sRowErrorproperty to see the actual reason.