Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

Failed to enable constraints

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Crazy Cat - 28 Jan 2008 22:29 GMT
I've created a dataset that includes a tableadapter and table for
countries. Here is the table schema

CREATE TABLE [CAT].[Countries](
    [CountryID] [smallint] IDENTITY(1,1) NOT NULL,
    [RegionID] [smallint] NOT NULL,
    [CountryCode] [varchar](12) NULL,
    [CountryName] [nvarchar](100) NOT NULL,
    [Recognized] [bit] NOT NULL CONSTRAINT [DF_Country_Recognized]
DEFAULT ((1))
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [CAT].[Countries]  WITH CHECK ADD  CONSTRAINT
[FK_Countries_to_Regions_by_RegionID] FOREIGN KEY([RegionID])
REFERENCES [CAT].[Regions] ([RegionID])
GO
ALTER TABLE [CAT].[Countries] CHECK CONSTRAINT
[FK_Countries_to_Regions_by_RegionID]

The contents of the table is 251 rows.

The contents of the table are retrieved via a stored procedure --

USE [FCAST]
GO
/****** Object:  StoredProcedure [CAT].[usp_select_countries]
Script Date: 01/28/2008 17:22:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================

-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [CAT].[usp_select_countries]
    -- Add the parameters for the stored procedure here
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

   -- Insert statements for procedure here
    SELECT [CountryID]
         ,[RegionID]
         ,[CountryCode]
         ,[CountryName]
         ,[Recognized]
    FROM CAT.[Countries]
    ORDER BY CountryName ASC
END

When I attempt to set the datasource of a combo box in the following
manner

combobox.datasource = adapter.getdata where adapter is a tableadapter
for the country table

I get the following error {"Failed to enable constraints. One or more
rows contain values violating non-null, unique, or foreign-key
constraints."}

I've checked the table -- no primary key violations or null exceptions
that I can see -- I even change the stored procedure so that it just
returns the first five rows just to prove to myself I'm not crazy and
I still get this same   error! What's funny is that this code worked
for the last few months -- this morning I had to rebuild part of the
dataset (because of surprise, surprise, another stupid MicroCrap
error) and suddenly this I get this error on this one table.

Can anyone help ? I am beyond frustrated.

Thanks,
Crazy Cat - 29 Jan 2008 04:20 GMT
> I've created a dataset that includes a tableadapter and table for
> countries. Here is the table schema
[quoted text clipped - 74 lines]
>
> Thanks,

I solved this problem by taking the offending tableadapter and
datatable and adding them to a separate dataset.
No idea why in one dataset it works and causes this totally cryptic
error in another.

Thanks microsoft for costing me a day's work chasing your bugs.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.