title: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. asp.net c#
body: <p>I have to get start date and end date from two text box and according to that date's I have to fetch data from db and display into a grid view.</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {    
      String str = DateTime.Now.ToString(TextBox1.Text);
      DateTime tm = Convert.ToDateTime(str);
      String str2 = DateTime.Now.ToString(TextBox2.Text);
      DateTime tm2 = Convert.ToDateTime(str2);
  
      solarDataSet2TableAdapters.tbl_energy_reportTableAdapter state;
      state = new solarDataSet2TableAdapters.tbl_energy_reportTableAdapter();
  
      DataTable dt = new DataTable();  
      dt = state.GetGridDataBy(DropDownList1.SelectedValue,DropDownList2.SelectedValue,  
  
      str, str2);  // Failed to enable constraints. One or more rows contain values  
      //violating non-null, unique, or foreign-key constraints. asp.net c#  
  
      GridView1.DataSource = dt;
      GridView1.DataBind();
  }
  </code></pre>