Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Failed to enable constraints
Message
From
11/01/2011 10:22:08
 
 
To
11/01/2011 10:08:23
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01495470
Message ID:
01495628
Views:
28
Hi Tim,

that's what I did to verify there were no nulls in the data.

What should I look for in my Business Object that could be causing it?

Here's where I think I am doing something wrong:

I have a Receipt BO and a Receipt Detail BO. When I save the entire receipt I want to print the receipt so I call a method on the receipt BO which brings back the fields from the Receipt Detail and Receipt tables, which I then pass to my Reporting code.

>Hi Frank,
>
>I would suggest if you havn't already done this is go into SQL Server Management studio and right click that stored procedure and choose execute stored procedure. Paste in the parameter value for a receipt that has two detail lines and verify that stored procedure runs OK and if so inspect the data. This way you can confirm if there is a problem with the data returned or if there is a problem in your business objects that would be causing it.
>Tim
>
>
>>Well, I did this prior to getting the data:
>>
>>
this.oReceipt.DataSet.EnforceConstraints = false;
>>
>>and that has at least let the code run. But it feels to me like I am just treating the symptom and not fixing the actual problem (which is probably my misunderstanding of how things are supposed to work).
>>
>>
>>>Hi Bob,
>>>
>>>unfortunately no NULLs are being returned. I'm wondering if the problem is due to multiple rows being returned. Would I need to return it to an EntityList rather than an Entity? (LATER: I changed the code to return an entitylist but the same error occurs.) My Code is this:
>>>
>>>In the class definition:
>>>
>>>
protected Receipt oReceipt;
>>>
>>>Where the error occurs:
>>>
>>>
                mmSaveDataResult result = this.Save(this.oReceipt, this.dsReceipt, this.oReceipt.TableName);
>>>                if (result == mmSaveDataResult.RulesPassed)
>>>                {
>>>                    LocalReport report = new LocalReport();
>>>                    report.ReportPath = "ReceiptPrint.rdlc";
>>>                    this.oReceipt.GetReceiptByPKForPrint(this.oReceipt.Entity.ReceiptPK);
>>>                    DataSet dsReceipt = oReceipt.DataSet; // (DataSet)Session["dsReceipt"];
>>>                    report.DataSources.Add(new ReportDataSource("ReceiptPrint_Receipt", dsReceipt.Tables[0]));
>>>
>>>                    Reporting oPrint = new Reporting();
>>>
>>>                    oPrint.Export(report);
>>>                    oPrint.m_currentPageIndex = 0;
>>>                    oPrint.Print();
>>>...
>>>
>>>
>>>>Frank,
>>>>
>>>>I have got this error a few times and every time it had to do with nulls being returned in the result set. I always fixed it by removing the null value in the column by using the ISNULL function and returning 0 if a number or a blank space if characters.
>>>>
>>>>HTH
>>>>
>>>>Bob
>>>>>Hi,
>>>>>
>>>>>using MM.NET 3.6 and VS2008.
>>>>>
>>>>>I'm not sure if this is a Mere Mortals thing or more general. I'm getting this error:
>>>>>
>>>>>
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. 
>>>>>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
>>>>>
>>>>>Exception Details: System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
>>>>>
>>>>>Source Error: 
>>>>>
>>>>>Line 44:         public ReceiptEntity GetReceiptByPKForPrint(Guid receiptPK)
>>>>>Line 45:         {
>>>>>Line 46:             return this.GetEntity("ReceiptsSelectByPKForPrint",
>>>>>Line 47:                 this.CreateParameter("@ReceiptPK", receiptPK));
>>>>>Line 48:
>>>>>
>>>>>This is called when I want to print a receipt that has just been added to the database. It works when there is only one detail line in the receipt but when there are two lines I get this error.
>>>>>
>>>>>Any ideas as to what could be wrong here?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform