title: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. error in VB.Net
body: <p>There were three similar questions in StackOverFlow but none gave an answer..</p>
  
  <p>If have found why this error in occurring but don't know the fix.</p>
  
  <p>I am using <code>Strongly Typed Dataset</code> for my project which is created as a dll for DAL.</p>
  
  <p>I have added the Sql Server Table into this dataset using the designer and has created a DataAdapter</p>
  
  <p><img src="https://i.stack.imgur.com/CgJIv.png" alt="This is how the datatable looks"></p>
  
  <p>It works fine when i insert using DataTableAdapter</p>
  
  <pre><code>daLabTest.Insert(txtLabTestId.Text, cmbLabTestType.Text, cmbTestName.Text, txtLabFees.Text, dtpLabEffDate.Value)
  </code></pre>
  
  <p>but when i want to show the data from the table in a combobox or gridview i get this error.</p>
  
  <p><img src="https://i.stack.imgur.com/t3soz.png" alt="Error showned in visual Studio"></p>
  
  <p>i told that i found out what the problem is, I just previewed the data using DataSet designer and found out that the Function returns data like this...</p>
  
  <p><img src="https://i.stack.imgur.com/gFpiE.png" alt="data i got preview"></p>
  
  <p>The query i wrote to view this in dataset is </p>
  
  <pre><code>Select distinct(TestType) from LabTestTypes
  </code></pre>
  
  <p>so this should return only one column but the dataset is returning 5 columns but others as null, and the <code>TestName</code> column is a primary which should not be null when returned, so the problem exists..</p>
  
  <p>To resolve this i tried to change the <code>NullValue</code> &amp; <code>AllowDBNull</code> property to <code>[Empty]</code> and <code>true</code> respectively but that didn't worked for me.</p>
  
  <p>Please help me in this...</p>