System.Data.ConstraintException on selecting many rows


I want to select a lot of usernames in my drop down list. In the second row of my initListbox function I get the exception (non-null, unique or foreign-key)...

1    PersonenTableAdapter ps = new PersonenTableAdapter();
2            List<Security.PersonenRow> users = new List(ps.GetData());
4            users.Sort(delegate(Security.PersonenRow a, Security.PersonenRow b)
5                {
6                    return a.Benutzername.CompareTo(b.Benutzername); 
7                });
9            UserList.DataSource = users;
10           UserList.DataBind();

The GetData Method has the following sql query behind:

order by oid


The table has about 5000 entries. When I change my where clause to "rownum < 500" it works. When I set it to < 1000 or leave the clause I get a System.Data.ConstraintException!

What goes wrong here???



4/23/2009 2:17:56 PM 2269 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 54


I did further testing - it works until rownum < 745. On rownum < 746 I get the mentioned exception:

[ConstraintException: Einschränkungen konnten nicht aktiviert werden. Mindestens eine Zeile enthält Werte die die Einschränkungen non-null, unique or foreign-key verletzen.]
   System.Data.DataTable.EnableConstraints() +1844613
   System.Data.DataTable.set_EnforceConstraints(Boolean value) +42
   System.Data.DataTable.EndLoadData() +217
   System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +229
   System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) +312
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +210
   System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +162
   System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +115
   SecurityTableAdapters.PersonenTableAdapter.GetData() in c:\Users\Markusg\AppData\Local\Temp\Temporary ASP.NET Files\verpackung\90b9f23d\6e84893a\App_Code.amhhr8dd.5.cs:2433
   security_RechteVerwalten.loadUserDropdownList() in c:\Work\Projekte\UFH\verpackung\src\app\Verpackung\security\RechteVerwalten.aspx.cs:34
   security_RechteVerwalten.Page_Load(Object sender, EventArgs e) in c:\Work\Projekte\UFH\verpackung\src\app\Verpackung\security\RechteVerwalten.aspx.cs:18
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

In the table only the oid column is mandatory - all the others are nullable. And also on the DataTable only the property oid has the attribute "NullValue=Throw Exception" - all the others have "NullValue=Empty"!

Has anyone an idea?


4/23/2009 6:28:53 PM

In your codes, do you expect to assign only one row of data to that or not?

Many Thanks & Best Regards,
HuaMin Chen

(Mark it as answer if it does help you!)
4/27/2009 9:36:00 AM


No I wanted to fill a drop down list with one column of all the rows returned. But I have solved it yesterday. I did the following:

  • created a new dataset Person2 with a new Tableadapter2
  • modified the columns like in the original dataset
  • copied all the querys, inserts, updates, delete statements from the original dataset
  • changed the sub to fill the drop down list with the new tableadapter
  • EVERYTHING WORKS like expected (without any error)

So PLEASE explain! Stick out tongue

When I switch back to the original tableadapter the old error occurs again. I always thought asp net is a good framework but such a behaviour places a big shade over asp net...

I'm developing with Visual Web Developer 2008 SP1.


4/28/2009 6:11:42 AM

Similar Artilces:

which is shou i use? Microsoft .NET Framework 1.1 Data Provider for Oracle and the Oracle Data Provider for .NET
Microsoft .NET Framework 1.1 Data Provider for Oracle and the Oracle Data Provider for .NETI am confused?Which is better or which one should I use?BTW, I am going to use .net 2.0 with oracle 9. Can anyone tell me what shou I use for working with oracle database?Thanks very much in advance!Justin Oracle's data provider has more functionality than Microsoft's.If your doing transaction processing you can have SAVEPOINTs, which Microsoft's data provider does not provide.Also, Oracle has PL/SQL Associative Arrays which are very powerful.Oracle also allows you to bind parameters by name and pos...

How call a Oracle Function using Microsoft .Net Oracle Client (System.Data.OracleClient)?
I try to call Oracle Function in .net C# by using System.Data.OracleClient. But i am not successful. Here is my code FUNCTION TTHAO_MONTT_EXISTS ( vten varchar2) RETURN boolean IS ret boolean; montt_id integer; BEGIN ret:=false; montt_id:= -1; select monthethao_id into montt_id from TTHAO_MONTHETHAO where ten = vten; if montt_id!=-1 then ret:=true; end if; return ret; Exception when others then return false; END; I do not know, when I call function TTHAO_MONTT_E...

urgent: .NET Provider for Oracle or Oracle Data Provider for .NET
If I want to access Oracle DB in ASP.NET application, and I am using .NET Provider for Oracle or Oracle Data Provider for .NET, should I have to install OracleClient on my .NET server? Is there other choice? Thank you very much.Johnson Johnson2007:should I have to install OracleClient on my .NET server?  You have to options1. install the ODP.NET on your web serverOR2. put the oracle assemblies in your BIN directory   Hi jimmy,Thank you for you reply. Because I could not find a server right now, I should test it first before I agree or disagree with you, as most articles I...

How to select data from a table and insert the selected data in the same table as new row
Hi    I have a table called Version and its attributes are Version_ID, Project_ID , Hospital_ ID , Date_Created and comments. I want to select the data by Version_ID,Project_ID and  Hospital_ID and the selected data is inserted in the same table(Version) as new row . Table: Version (Version_ID(Primary_key), Project_ID(Foreign_Key),Hospital_ID(Foreign_Key),Date_Created,Comments).  Iam using Visual Web Developer Express 2005 and SQL Server 2005. Iam doing on 2.0. Could anyone please send me the code in 2.0 for the above problem. ...

Problems retrieving REF Cursor with .Net Oracle Provider (System.Data.OracleClient)
Hi , I created a package which recieves 3 parameters. One of them, is a type that I created using ref cursor, likewise the example provided in the .Net Oracle Client Documentation and inside msdn site ( the part which talks about Ref Cursor). I´ve already tested the package, and it´s working properly. But when I tried to run the ExecuteReader method of my Oracle Command I got the error "PLS-00306: wrong number or types of arguments in call to 'PAGINAR'". Her...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

Difference between System.DataAccess.Oracle and System.Data.OracleClient
Hello, Can anybody out there tell me the difference between using System.DataAccess.Oracle and System.Data.OracleClient ? I am using System.Data.OracleClient, however I noticed in some postings that people are using System.DataAccess.Oracle. I would like to know what are the difference between the two ODP.Net provider. Thanks in advance. System.Data.OracleClient is from Microsoft, this will come along with .Net frame work 1.1! But the other one you have to download from! This is from Oracle, you have ...

Retrieve data row by row and multiple SELECT statements.
hai to all experts out there,can somebody help me please! I would like to do this sql select statement in in order to display the output in a gridview. I have a table name TBL_DOC consist of ID,DOC_NO,PIC_FLAG,MPIC1,MPIC2,MPIC3,MPIC4 ,MPIC5 columns. My intention is first i want to retrieve PIC_FLAG column data from all rows in TBL_DOC table  row by row like this: SELECT PIC_FLAG FROM TBL_DOC and then if PIC_FLAG = 'MPIC1' i want to do another select statement like this in the same table: SELECT ID,DOC_NO,PIC_FLAG,MPIC1 FROM TBL_DOC where PIC_FLAG = 'MPIC1...

Display data in one row with many child rows
Hi all, Could i display data like this :                             DetailPerson        Column 1       Column 2                   name 1         address 1person 1      age 1         &nbs...

Exception Details: System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Hi, I have two data objects, a gridview and detailsview.The gridview has a LinkButton which is the unique identifier for the row<asp:LinkButton ID="lbEmployeeID" CommandName = "Select" runat ="server" Text='<%# Eval("EmployeeID") %>' /> My goal is not to use SQLDataSource nor ObjectDataSource and control the queries from the code behind file. Somethings work and others do not. If I use the SqlDataSource with a Stored Procedure to populate the detailsview-no errors.  However I get an error when attempting to delete a...

The .Net Data SQL Provider (System.Data.SqlClient) requires Microsoft Data Access Components(MDAC) version 2.6 or later.
I am getting error like The .Net Data SQL Provider (System.Data.SqlClient) requires Microsoft Data Access Components(MDAC) version 2.6 or later. i am working with windowsXP. Already in my system i have MDAC 2.7. I donot know why am i getting error like this. anybody help me please...

I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.
 Hi, Let say I've 4 rows in a table. I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row. Thanks in advance Asghar Ali Mohammed Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you. If you can use Linq, you can use Skip., EdMicrosoft MVP - ASP/ASP.NET Hii dear..U can fire the Query select Top(3) from Table1 order by id desc.. "A conclusion is whe...

System.Data, Is ADO.NET is the best way to access data
   Can any one give me simple example on how to open a cursor to get data and field names and types. Is this the best way?  The System.Data namespace provides access to classes that represent the ADO.NET architecture. ADO.NET lets you build components that efficiently manage data from multiple data sources.  Is this a good example.  Is this efficient?  How do I also print the field names?  Please help DataSet GetData(String queryString) { // Retrieve the connection string stored in the Web.config file. String connectionString = ConfigurationManager...

Gridview row 0 selected, but data for row+1 is displayed... ??
Hello. Here's a rather interesting dilemma--hopefully easy to solve? Though I'm stumped for the moment, so any help will be greatly appreciated. I have a gridview with master records listed. The records are acquired using L2S and a sproc that applies Row_Number() to the results for custom paging. The resultset looks fine. It binds to the gridview as expected (displaying data for rows 1 through 5). Each master record has a "select" column to allow the user to select which master record to display in the detail record view. When select is clicked, the child records are&...

Web resources about - System.Data.ConstraintException on selecting many rows -

Resources last updated: 12/28/2015 11:45:45 PM