Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Failed to enable constraints
Message
From
11/01/2011 19:07:23
 
 
To
11/01/2011 17:19:16
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:
01495817
Views:
38
No problem Tim.

Now I need to work out how to do reports properly :) But that's for tomorrow.

>Hi Frank,
>
>Sorry, I got sidetracked with a customer. I see that Rob gave you an answer and you got it worked out.
>Tim
>
>>Tim,
>>
>>I've tried to change it, but I still get the same error about Failed to enable constraints (even if I uncomment the code to set EnforceConstraints = false). Here's my code:
>>
>>
                    //this.oReceipt.DataSet.EnforceConstraints = false;
>>                    //this.oReceipt.GetReceiptByPKForPrint(this.oReceipt.Entity.ReceiptPK);
>>                    //DataSet dsReceipt = oReceipt.DataSet; // (DataSet)Session["dsReceipt"];
>>                    DataSet dsReceiptPrint = this.oReceipt.GetReceiptByPKForPrint(this.oReceipt.Entity.ReceiptPK);
>>                    report.DataSources.Add(new ReportDataSource("ReceiptPrint_Receipt", dsReceiptPrint.Tables[0]));
>>
>>This is the method:
>>
>>
        public DataSet GetReceiptByPKForPrint(Guid receiptPK)
>>        {
>>            return this.GetDataSet("ReceiptsSelectByPKForPrint",
>>                this.CreateParameter("@ReceiptPK", receiptPK));
>>        }
>>
>>Have I done something wrong?
>>
>>
>>>The problem with this is you are trying to return this as a Receipt Entity with this code. Your Receipt Entity does not contain all the fields for this type of data being returned.
>>>
>>>public ReceiptEntity GetReceiptByPKForPrint(Guid receiptPK)
>>>{
>>>           return this.GetEntity("ReceiptsSelectByPKForPrint",
>>>                 this.CreateParameter("@ReceiptPK", receiptPK));
>>>
>>>
>>>Try changing your business object method to return a DataSet instead and then use the method GetDataSet rather than GetEntity. Obviously you will have to change your method a bit that retrieves the data to accept the dataset instead.
>>>Tim
>>>
>>>
>>>>This is the stored procedure:
>>>>
>>>>
	SELECT  Receipts.ReceiptDate, Receipts.ReceiptAmount, Receipts.ReceiptNumber, PolicyHeaders.PolicyNumber, Receipts.ReceiptPK, ReceiptDetails.ChequeNo, 
>>>>               ReceiptDetails.AmountReceived, ReceiptDetails.NumberOfPremiums, ReceiptTypes.ReceiptType, PaymentTypes.PaymentType
>>>>FROM     Receipts INNER JOIN
>>>>               PolicyHeaders ON Receipts.PolicyHeaderFK = PolicyHeaders.PolicyHeaderPK INNER JOIN
>>>>               ReceiptDetails ON Receipts.ReceiptPK = ReceiptDetails.ReceiptFK INNER JOIN
>>>>               PaymentTypes ON ReceiptDetails.PaymentTypeFK = PaymentTypes.PaymentTypePK INNER JOIN
>>>>               ReceiptTypes ON ReceiptDetails.ReceiptTypeFK = ReceiptTypes.ReceiptTypePK
>>>>	WHERE 
>>>>		([ReceiptPK] = @ReceiptPK)
>>>>
>>>>
>>>>It is basically de-normalising the tables for the report (this is just the way I do it for VFP reports so let me know if there is a better way to do it for Reporting Services reports). I don't know much about Reporting Services yet so I do not know what I can pass to it or not.
>>>>
>>>>
>>>>
>>>>>Hi Frank,
>>>>>
>>>>>Does the Stored Procedure return rows from both the Receipt and ReceiptDetail tables? It appears you are trying to return and Entity or Entity list from the Receipt business object. How can a Entity object have a row from one table and multiple rows from another? Can you post your Stored Procedure here? Is the data un-normalized for the report then? Can you pass a parent record to the report as well as a child table?
>>>>>
>>>>>If you can use a dataset in the report with two tables that may be a good choice. Then your business object can retrieve the parent receipt row as a dataset and add to the dataset the table for the child rows that are related.
>>>>>Tim
>>>>>
>>>>>>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
>>>>>>>
Frank.

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

Click here to load this message in the networking platform