Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi this is my Stored Procedure on SQL Server 2008
 
ALTER PROCEDURE getEmailThemes
AS
BEGIN
	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
END
GO
 
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(); ;
            Connection.Open();
            SqlDataReader dr = Command.ExecuteReader();
            dt.Load(dr);
            NumberOfCategory = dt.Rows.Count - 1;
            //string[][] EmailArchives = new string[NumberOfCategory][];
            string[] Tbody = new string[NumberOfCategory];
            drpCategoryList.DataSource = dt;
            drpCategoryList.DataValueField = "Title";
            drpCategoryList.DataTextField = "Title";
            drpCategoryList.DataBind();
 
            dt.Clear();
            command = "getEmailThemes";
            Command.CommandText = command;
            SqlDataReader dre = Command.ExecuteReader();
            dt.Load(dre); //error

          
 
           Connection.Close();
 
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
Comments
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)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2014
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