Reputation: 3293
I have a table with following columns
EndDate DateTime AllowNulls
IsApproved Bit AllowNulls
When I send a select query to my table, these two columns generates error.
Lets say this is my select query.
SELECT S.Name, S.Surname,
CASE
WHEN S.EndDate IS NOT NULL AND S.IsApproved = 1 THEN 'Left'
WHEN S.EndDate IS NOT NULL AND S.IsApproved = 0 THEN 'Waiting'
WHEN S.EndDate IS NULL AND S.IsApproved IS NULL THEN 'Joined'
ELSE ''
END AS Durumu
FROM STUDENT S
The error I receive: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints
My question is how can I select these null columns appropriately?
P.S. this error has nothing to do with returning same query with same primary key because I have only one entry in my table :)
Upvotes: 0
Views: 146
Reputation: 460058
I assume you're using a strongly typed DataSet to get your data, am i right?
This error is not raised by your database but by your DataSet
.
You can check what caused the exception in this way:
DataTable
/DataSet
.DataTable.GetErrors
to get all rows which RowError
is setMaybe you just have to refresh the table via the configuration window, because meanwhile you have changed the constraints in sql-server.
Upvotes: 2