I searched a lot, but could not find the solution.
I get the error:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
I run DataTable.GetErrors()
and see that some columns are set to Not NULL
in SQL Compact Edition Database. And these columns are used in LEFT OUTER JOIN
query so they are null when the query is run. (I can get the results when i run the query in Server Explorer in VS).
The error occurs when trying to load the data in Datatable:
using (SqlCeCommand Cmd = new SqlCeCommand("Query HERE", "Connection HERE"))
{
C.Open();
using (SqlCeDataReader Rdr = Cmd.ExecuteReader())
{
DataTable DT = new DataTable();
DT.Load(Rdr);
return DT;
}
}
I tried so many solutions to overcome this however i was not able to solve it. I know about "EnforceConstraints" however as i do not use any dataset, i can not change that property.