title: ASP.NET dataset getdataBy Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign key constraints
body: <p>hi
  i have a very simple webform
  i have a button and a gridview on this form and a dataset that contains linked tables bill, docket, docket_bill etc.</p>
  
  <p>On Button click i use the following code</p>
  
  <pre><code>  protected void button_click(object sender, EventArgs e)
  {
  billTableAdapter Billta = new billTableAdapter();
  gridview1.datasource = Billta.getTop20Bills();
  gridview1.databind()'
  }
  </code></pre>
  
  <p>Now when i click on the button, i get the following error</p>
  
  <blockquote>
    <p>"Failed to enable constraints. One or
    more rows contain values violating
    non-null, unique, or foreign key
    constraints"</p>
  </blockquote>
  
  <p>However, when i change the code to </p>
  
  <pre><code> protected void button_click(object sender, EventArgs e)
      {
      billTableAdapter Billta = new billTableAdapter();
      gridview1.datasource = Billta.getdata();
      gridview1.databind()'
      }
  </code></pre>
  
  <p>It works fine. billTa.getData() gets all the rows from the dataset and shows up in the gridview. but when i add a query and select only few columns, then it gives me the aforementioned error.</p>
  
  <p>Any idea what is wrong here?</p>
  
  <p><code>SQL Scripts for getdata() = select * from bill</code> <Br></p>
  
  <pre><code>SQL script for getTop20Bills = select top 20 bill_id, bill_amount from bill
  </code></pre>