Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign

Discussion in 'ASP .Net' started by Bobby Edward, Oct 31, 2008.

  1. Bobby Edward

    Bobby Edward Guest

    I have an xsd dataset. I created a simple query called GetDataByUserId. I
    can preview the data fine!

    I created a very simple BLL function that calls it and returns a datatable.

    When I run the code I get....

    =======================

    Server Error in '/MyCompanyMyProject' Application.
    Failed to enable constraints. One or more rows contain values violating
    non-null, unique, or foreign-key constraints.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.Data.ConstraintException: Failed to enable
    constraints. One or more rows contain values violating non-null, unique, or
    foreign-key constraints.

    Source Error:

    Line 2366: End If
    Line 2367: Dim dataTable As dsUsers.myoptionsDataTable = New
    dsUsers.myoptionsDataTable
    Line 2368: Me.Adapter.Fill(dataTable) <==== LINE IS IN RED!
    Line 2369: Return dataTable
    Line 2370: End Function

    Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
    Files\MyCompanyMyProject\7eeeedcd\743a3129\App_Code.zobkgcsa.15.vb Line:
    2368

    =======================

    Any idea why?

    I verified all the data, that no pk/fk are violated, etc... Even when I
    turn 'enforce constraints' off in the xsd dataset properties it still fails.
     
    Bobby Edward, Oct 31, 2008
    #1
    1. Advertising

  2. Bobby Edward

    sloan Guest

    You have to ~~anally~~ go over the column names...of your ResultSet.
    And compare to the strong dataset.

    ~anally~

    Every columnName....

    My guess is that you're either not returning a certain column or ... you
    have a mismatched name.

    Select LastName from dbo.Emp

    and you ds has "LName" in the column name or something like that.

    Check datatypes as well!



    "Bobby Edward" <> wrote in message
    news:...
    >I have an xsd dataset. I created a simple query called GetDataByUserId. I
    >can preview the data fine!
    >
    > I created a very simple BLL function that calls it and returns a
    > datatable.
    >
    > When I run the code I get....
    >
    > =======================
    >
    > Server Error in '/MyCompanyMyProject' Application.
    > Failed to enable constraints. One or more rows contain values violating
    > non-null, unique, or foreign-key constraints.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Data.ConstraintException: Failed to enable
    > constraints. One or more rows contain values violating non-null, unique,
    > or foreign-key constraints.
    >
    > Source Error:
    >
    > Line 2366: End If
    > Line 2367: Dim dataTable As dsUsers.myoptionsDataTable = New
    > dsUsers.myoptionsDataTable
    > Line 2368: Me.Adapter.Fill(dataTable) <==== LINE IS IN RED!
    > Line 2369: Return dataTable
    > Line 2370: End Function
    >
    > Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
    > ASP.NET Files\MyCompanyMyProject\7eeeedcd\743a3129\App_Code.zobkgcsa.15.vb
    > Line: 2368
    >
    > =======================
    >
    > Any idea why?
    >
    > I verified all the data, that no pk/fk are violated, etc... Even when I
    > turn 'enforce constraints' off in the xsd dataset properties it still
    > fails.
    >
    >
     
    sloan, Oct 31, 2008
    #2
    1. Advertising

  3. Bobby Edward

    Bobby Edward Guest

    Thanks.

    It's a simple SELECT of all the fields in the table WHERE xxxx = input
    param. When I preview it (in dataset designer) it's fine, even passing it
    the same variable.

    When I run it thru code it fails.

    Any ideas?

    "sloan" <> wrote in message
    news:...
    >
    > You have to ~~anally~~ go over the column names...of your ResultSet.
    > And compare to the strong dataset.
    >
    > ~anally~
    >
    > Every columnName....
    >
    > My guess is that you're either not returning a certain column or ... you
    > have a mismatched name.
    >
    > Select LastName from dbo.Emp
    >
    > and you ds has "LName" in the column name or something like that.
    >
    > Check datatypes as well!
    >
    >
    >
    > "Bobby Edward" <> wrote in message
    > news:...
    >>I have an xsd dataset. I created a simple query called GetDataByUserId.
    >>I can preview the data fine!
    >>
    >> I created a very simple BLL function that calls it and returns a
    >> datatable.
    >>
    >> When I run the code I get....
    >>
    >> =======================
    >>
    >> Server Error in '/MyCompanyMyProject' Application.
    >> Failed to enable constraints. One or more rows contain values violating
    >> non-null, unique, or foreign-key constraints.
    >> Description: An unhandled exception occurred during the execution of the
    >> current web request. Please review the stack trace for more information
    >> about the error and where it originated in the code.
    >>
    >> Exception Details: System.Data.ConstraintException: Failed to enable
    >> constraints. One or more rows contain values violating non-null, unique,
    >> or foreign-key constraints.
    >>
    >> Source Error:
    >>
    >> Line 2366: End If
    >> Line 2367: Dim dataTable As dsUsers.myoptionsDataTable = New
    >> dsUsers.myoptionsDataTable
    >> Line 2368: Me.Adapter.Fill(dataTable) <==== LINE IS IN RED!
    >> Line 2369: Return dataTable
    >> Line 2370: End Function
    >>
    >> Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
    >> ASP.NET
    >> Files\MyCompanyMyProject\7eeeedcd\743a3129\App_Code.zobkgcsa.15.vb Line:
    >> 2368
    >>
    >> =======================
    >>
    >> Any idea why?
    >>
    >> I verified all the data, that no pk/fk are violated, etc... Even when I
    >> turn 'enforce constraints' off in the xsd dataset properties it still
    >> fails.
    >>
    >>

    >
    >
     
    Bobby Edward, Nov 1, 2008
    #3
  4. Bobby Edward

    Bobby Edward Guest

    Thanks I got it. Per your suggestion I went over it again. For some reason
    a field was marked as a PK where it shouldn't be. Wierd.

    THANKS SLOAN!!!
     
    Bobby Edward, Nov 1, 2008
    #4
  5. Bobby Edward

    sloan Guest

    Key word : Anally.

    Its always something super small.



    "Bobby Edward" <> wrote in message
    news:...
    > Thanks I got it. Per your suggestion I went over it again. For some
    > reason a field was marked as a PK where it shouldn't be. Wierd.
    >
    > THANKS SLOAN!!!
    >
     
    sloan, Nov 3, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bazzer
    Replies:
    1
    Views:
    4,969
    =?Utf-8?B?Y2xpY2tvbg==?=
    Apr 6, 2006
  2. H5N1
    Replies:
    0
    Views:
    442
  3. Jeff
    Replies:
    2
    Views:
    459
  4. Bobby Edward
    Replies:
    1
    Views:
    4,562
  5. cs_in_va

    Failed to enable constraints

    cs_in_va, Feb 19, 2008, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    176
    Mr. Arnold
    Feb 19, 2008
Loading...

Share This Page