Click here to Skip to main content
11,930,788 members (57,983 online)
Rate this:
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 6:37am
Sandeep Mewara 7-Feb-13 11:41am
I don't see any link of code-behind with stored procedure. Confused.
Mike Meinz 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.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