njsokalski
Well-known member
- Joined
- Mar 16, 2011
- Messages
- 102
- Programming Experience
- 5-10
I am working on a web application that uses ASP.NET Membership. My SQL Server Database therefore includes (along with all the others created when setting up ASP.NET Membership) a table named aspnet_Users which has the fields ApplicationId, UserId, UserName, LoweredUserName, MobileAlias, IsAnonymous, LastActivityDate. I also have a table named CatalogItems which has a primary key field named ID, which is of type Int. I want to allow my users to create wishlists. I created the following table to do this:
Create Table WishLists (UserId UniqueIdentifier Not Null Foreign Key References aspnet_Users(UserId) On Delete Cascade,
ItemId Int Not Null Foreign Key References CatalogItems(ID) On Delete Cascade,
Constraint PK_Id Primary Key (UserId,ItemId))
I am using an *.xsd dataset for both of these tables, and everything works fine for the CatalogItems table, and items get added to the WishLists table perfectly fine, but then I recieve the following error:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
The correct data gets inserted into the WishLists table just like I would expect. I even tried redeclaring the WishLists table without any constraints, but I still recieve the error. What is the problem here, and what do I need to do to fix it? Any help would be appreciated. Thanks.
Create Table WishLists (UserId UniqueIdentifier Not Null Foreign Key References aspnet_Users(UserId) On Delete Cascade,
ItemId Int Not Null Foreign Key References CatalogItems(ID) On Delete Cascade,
Constraint PK_Id Primary Key (UserId,ItemId))
I am using an *.xsd dataset for both of these tables, and everything works fine for the CatalogItems table, and items get added to the WishLists table perfectly fine, but then I recieve the following error:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
The correct data gets inserted into the WishLists table just like I would expect. I even tried redeclaring the WishLists table without any constraints, but I still recieve the error. What is the problem here, and what do I need to do to fix it? Any help would be appreciated. Thanks.