Click here to Skip to main content
11,798,866 members (43,739 online)
Rate this: bad
Please Sign up or sign in to vote.
Hi this is my Stored Procedure on SQL Server 2008

	SELECT EpaperTheme.ID AS ThemeID, EpaperTheme.Title AS Title, EpaperTheme.CreationDate, MarketingCategory.Title AS Category
	FROM EpaperTheme JOIN MarketingCategory ON EpaperTheme.Category_ID = MarketingCategory.ID

and this is my code behind
string ConnectionString = "Data Source=.;Initial Catalog=myDatabase;Integrated Security=SSPI";
            SqlConnection Connection = new SqlConnection(ConnectionString);
            string command = "SELECT * FROM MarketingCategory";
            SqlCommand Command = new SqlCommand(command, Connection);
            DataTable dt = new DataTable(); ;
            SqlDataReader dr = Command.ExecuteReader();
            NumberOfCategory = dt.Rows.Count - 1;
            //string[][] EmailArchives = new string[NumberOfCategory][];
            string[] Tbody = new string[NumberOfCategory];
            drpCategoryList.DataSource = dt;
            drpCategoryList.DataValueField = "Title";
            drpCategoryList.DataTextField = "Title";
            command = "getEmailThemes";
            Command.CommandText = command;
            SqlDataReader dre = Command.ExecuteReader();
            dt.Load(dre); //error


but when i execute the code, gets this error:

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

how can i solve this problem??
Posted 7-Feb-13 5:37am
Sandeep Mewara at 7-Feb-13 11:41am
I don't see any link of code-behind with stored procedure. Confused.
Mike Meinz at 7-Feb-13 12:20pm
1. Use the Visual Studio Debugger and step through your code to determine which line throws the exception. Then determine the values of the pertinent variables at that time.

2. Try running your SQL in a query window within SQL Server Management Studio to help you pinpoint the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 465
1 OriginalGriff 378
2 Maciej Los 305
3 Richard MacCutchan 281
4 phil.o 244
0 OriginalGriff 2,270
1 Maciej Los 1,810
2 KrunalRohit 1,496
3 CPallini 1,425
4 Richard MacCutchan 1,109

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100