• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 846
  • Last Modified:

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

0
RobertNZana
Asked:
RobertNZana
  • 3
  • 2
1 Solution
 
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
 
RobertNZanaAuthor Commented:
couldnt figure it out
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now