Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Using Visual Studio with MySQL.

In my XSD dataset I created a query. It runs perfect. I can preview the data fine.

In my BLL I wrote code (see below) to retrieve the query results and I'm getting...
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Why would previewing the data work but in code it fails?

Any ideas?
Using db As New dsDemoTableAdapters.DemoTableAdapter
     Dim dt As New DataTable
     dt = db.GetDemo(DemoId) ' ERROR HAPPENS HERE

Open in new window

LVL 9
RobertNZanaAsked:
Who is Participating?
 
RobertNZanaConnect With a Mentor Author Commented:
couldnt figure it out
0
 
puru1981Commented:
are you using same id to for query and preview?

if not then please check if the query is returning null on some fields in join or duplicate data.
0
 
RobertNZanaAuthor Commented:
the param (DemoId) is the exact same

i can literally see the data results when i preview the query in the xsd dataset
0
 
puru1981Commented:
this is strange...i don't see any reason for this...
0
 
RobertNZanaAuthor Commented:
exactly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.