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.
On Button click i use the following code
protected void button_click(object sender, EventArgs e)
{
billTableAdapter Billta = new billTableAdapter();
gridview1.datasource = Billta.getTop20Bills();
gridview1.databind()'
}
Now when i click on the button, i get the following error
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign key constraints"
However, when i change the code to
protected void button_click(object sender, EventArgs e)
{
billTableAdapter Billta = new billTableAdapter();
gridview1.datasource = Billta.getdata();
gridview1.databind()'
}
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.
Any idea what is wrong here?
SQL Scripts for getdata() = select * from bill
SQL script for getTop20Bills = select top 20 bill_id, bill_amount from bill