how to eliminatenon-null,unique or foreign-key constraints?

Last post 08-05-2003 10:09 AM by winn. 5 replies.

Sort Posts:

  • how to eliminatenon-null,unique or foreign-key constraints?

    08-02-2003, 11:04 PM
    • Member
      60 point Member
    • winn
    • Member since 06-20-2003, 11:00 PM
    • Posts 12
    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 164: SqlConnection1.Close()
    >Line 165:
    >Line 166: SqlDataAdapter1.Fill(DsChangePass1)
    >Line 167: Dim i As Integer =
    >DsChangePass1.CustomerDetails.Count
    >Line 168: If i > 0 Then

    the above error is what i got when i tried to run my program! could anyone tell me what's wrong with it and what does it actually require? apart from that, how am i going to validate it in order for me to manage the error!? thanks
  • Re: how to eliminatenon-null,unique or foreign-key constraints?

    08-03-2003, 12:23 PM
    • Contributor
      6,996 point Contributor
    • russnem
    • Member since 10-03-2002, 11:26 PM
    • Los Angeles, CA
    • Posts 1,389
    • ASPInsiders
      TrustedFriends-MVPs
    Are you familiar with what constraints are?
  • Re: how to eliminatenon-null,unique or foreign-key constraints?

    08-04-2003, 9:03 AM
    • Member
      60 point Member
    • winn
    • Member since 06-20-2003, 11:00 PM
    • Posts 12
    nope! i had no idea of what is that! but i did try to make the constraint to be false but then it's not working!
  • Re: how to eliminatenon-null,unique or foreign-key constraints?

    08-04-2003, 11:10 AM
    • Contributor
      6,996 point Contributor
    • russnem
    • Member since 10-03-2002, 11:26 PM
    • Los Angeles, CA
    • Posts 1,389
    • ASPInsiders
      TrustedFriends-MVPs
    A constraint is kind of like a rule. For example, if you design a database and you specify that a certain field MUST contain a value (cannot be null) you have created a constraint.

    If your table contains a foreign key and you specify that your foreign key MUST exist in your foreign key's parent table, you have created a foreign key constraint.

    If you can, take a look at the database tables that are involved with the query you are trying to run and find out what the constraints are. That should help you solve your problem.
  • Re: how to eliminatenon-null,unique or foreign-key constraints?

    08-05-2003, 6:33 AM
    • Contributor
      2,300 point Contributor
    • PD_Goss
    • Member since 07-09-2003, 8:10 AM
    • SC
    • Posts 460
    I'm having the same problem and what you say makes sense, I checked my table and it does have constraints to prevent nulls. So, are there any negative impacts other than allowing empty fields to be added to the table? If this is the case, my next line of thought would be to just write in Required Field Validators to prevent null entries on the page where the data is inserted into that table, ("if" this is the only side affect of changing the no nulls in the table.) Am I on the right track?

    Thanks.
  • Re: how to eliminatenon-null,unique or foreign-key constraints?

    08-05-2003, 10:07 AM
    • Member
      60 point Member
    • winn
    • Member since 06-20-2003, 11:00 PM
    • Posts 12
    well, i tried to went through my database, which is sql server 2000. i right click on my design table to go to relationship of the tables. I found a tab on constraints but there's nothing set over it. But i did do a foreign key for a field. So, does this mean that i need to code the constraint over the tab?i mean creating a constraint for it? what command should i use then? how to code it! i had no idea! hope can guide me through! thanks
Page 1 of 1 (6 items)