Wednesday, March 28, 2012

Report Parameter Errors

Hello.

I've been trying to figure this out for a day now and am getting frustrated. (ARGH!) As shown below, I have 4 parameters in my sproc. The @.Action is being set as "getAll", the @.FormID is coming from a textbox control, and the other 2 should allow nulls (this is in Local mode in a Web Form). I keep getting the error message below.

I do have these params defined in my .rdlc, then I'm setting the param values in my form's code-behind.

What am I doing wrong?


CREATE PROCEDURE dbo.spFormResults
(
@.Action VarChar( 20 ),
@.ResultID INT = NULL,

@.FormID int = NULL,

@.Data text = NULL
)
AS

.....


string strAction = "getAll";

ReportParameter actionParam = new ReportParameter("Action", strAction, false);

ReportParameter resultIDParam = new ReportParameter("ResultID", "0", false);

ReportParameter formIDParam = new ReportParameter("FormID", txtFormID.Text, false);

ReportParameter dataParam = new ReportParameter("Data", string.Empty, false);

this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { actionParam, resultIDParam,

formIDParam, dataParam });

this.ReportViewer1.LocalReport.Refresh();


An error has occurred during report processing.

  • Exception has been thrown by the target of an invocation.
  • Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    To me it seems you are looking in the wrong place for the error. It looks like the sort of error message that actually comes from the database, not RS. You need to check whether some of the columns you are searching on are set to NOT NULL in the schema.

    HTH,

    sluggy

    |||

    Yes, I thought that might be the case, too, but when I looked at it in the debugger, none of the parameters had values in them -- even though I was setting them in my code. So I'm still thinking the values of the params aren't being set somehow.

  • No comments:

    Post a Comment