crystal reports in c# / disable parameter prompt


  • Hi everyone,

    is there a way to disable the parameter prompt of the crystal report viewer in c# (2005 beta2)?

    I've got a simple report viewer, which doesn't have the smart tag to disable the parameter prompt as apparently the viewer for asp.net does, I'm loading a simple report with a parameter at runtime where I also set the parameter in the code, but still it'll prompt me for that anoying parameter and use the one from the prompt!!
    I didn't find any option in there (at least not in intelliSense...) to disable it...

    Any help much appreciated... thanks very much!

    12 Juli 2005 0:34


Semua Balasan

  • Hello Vince,

    This usually comes down to code or multiple parameters.  Check out the samples from our Devzone:


    In here is a sample called CS_Win_RDOBjMod_Parameters.  This might be give you some clues.

    Keith - Business Objects
    28 September 2005 19:46
  • Don't listen to keith he points everyone at that lame sample, even though he has been told multiple time that IT DOESN'T WORK! He has been given exact replications of the code and shown that it doesn't work. I'm beginning to wonder if he is a person at all or just some type of bot that watches this newsgroup and spits out a link to those samples at infrequent intervals.

    CR for VS2005 is broke, they released an update for CRXI (which you have to pay for) but haven't fixed CR for VS 2005. Guess their revenue stream is low and they lack any respect for any support for a product that was included with VS 2005.

    01 Januari 2006 7:27
  • Just curious - did you ever get this resolved?  I am having the same issue but can find no fix.  I have tried using the sample Business Objects code but It did not fix the issue




    18 Januari 2006 5:26
  • Hey Tom,

    sorry, don't even remember what that was about... so apparently I got it resolved somehow... actually I think I might have used MS Reporting Services instead... was getting annoyed with Crystal anyway.

    Sorry can't tell you more, honestly don't remember what I needed it for... used some kind of workaround.



    18 Januari 2006 5:34

    Been there, tried that,  Doing it tomorrow ;).  Well managed to find the solution for this problem.  The code is as following.

    discreteVal.Value = m_ReportParameterValue;


    paramField.CurrentValues.Add (discreteVal);

    paramField.HasCurrentValue = true;



    The magic is in the setting the ParamField.HasCurrentValue = True (and in my case I needed to Refresh the report.  Did not know why it was not enough just to set the param to true.)

    Well Enjoy.



    27 Januari 2006 10:06
  • Does this solve the problem with parameter prompting for linked parameters on subreports?

    I haven';t tried implementing your code yet. I did notice that RefreshReport is an event on the reportdocument not a method.

    27 Januari 2006 13:53
  • OK, I was able to get this to work for linked parameters which had the same name as the top level report parameters which were being passed in to the report request.

    I did this by populating all values for all parameters with the same name as the top level report parameters. Unfortunately this does not cover linked parameters which have a different name than the top level report parameter.

    Do you know any way of determining from the ReportDocument what the mapping is from top level parameters to subreport parameters?


    It does seem that this is headed in the right direction since I am not prompted for all subreport parameters, just the ones that are not the same name as the parameter to which they are linked. I just need to find the mapping so we don't have to change the reports/ or change the way that reports are being initiated.


    I just wish BO would fix it so this isn't necessary, it should be populating the linked parameters without having to explicitly set them when the connection context is changed.

    27 Januari 2006 14:35
  • OK, here is what I did. 

    Hashtable ht = new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer());
    repDoc.SetParameterValue(0, 91334);
    repDoc.SetParameterValue(1, 0);
    repDoc.SetParameterValue(2, 1033);
    repDoc.SetParameterValue(3, 14988);
    ht.Add(repDoc.ParameterFields[0].Name, repDoc.DataDefinition.ParameterFields[0].CurrentValues[0]);
    ht.Add(repDoc.ParameterFields[1].Name, repDoc.DataDefinition.ParameterFields[1].CurrentValues[0]);
    ht.Add(repDoc.ParameterFields[2].Name, repDoc.DataDefinition.ParameterFields[2].CurrentValues[0]);
    ht.Add(repDoc.ParameterFields[3].Name, repDoc.DataDefinition.ParameterFields[3].CurrentValues[0]);

    Then after setting the conninfo in the report and subreports. (I had to change the reportparameter names to match the linked subreport parameter names)

    foreach (ParameterField pf in repDoc.ParameterFields)
        if (ht.ContainsKey(pf.Name))
            pf.HasCurrentValue = true;
            Console.WriteLine(pf.Name + " = " + ((ParameterDiscreteValue)ht[pf.Name]).Value.ToString());

    Looks like this may be workable,although it requires going through all (100+) reports and modifying the parameters. Thanks for the pointer, Bad Tooth!

    27 Januari 2006 15:23
  • OK, still working on it.


    I get internittant errors when displaying the report in the viewer 'operation illegal on linked parameter'


    Seems like in the Hashtable iteration if i check for not only the existance of the parameter name in the hashtable but also whther the parameter belongs to a subreport (&& pf.ReportName.Length == 0) it stops having the errors when the report is displayed. So it must be cascading the value for the linked parameter, it must just not be triggering the cascade property set when using the SetParameterValue method on the reportdoc.

    27 Januari 2006 16:11
  • OK, final observations.

    I think the difference in the setparametervalue between 9.0 and 10.2 is that it triggeres a validatedatbase or a refresh when you do it in 10.2. This would explain the loss of values and the necessity of resetting the prametervalues directly.

    Just a guess. But I did revert back to the original report and did not have to rename the parameters after making sure that I was only setting the top level parameters after the conninfo was set on all tables in the report and subreport.

    If anyone is interested, I'll post the full code.

    27 Januari 2006 16:23


    It was buried in the Crystal support site and was dated 1/9/2006 and seems to only apply to Crystal Reports for VS 2005. IT WORKS HOORAY!!!!

    This fix eliminates the erroneous prompting for linked parameters after changing the database connection context for a report under CR for VS 2005.


    Direct link to patch


    13 Februari 2006 18:14
  • Let me say that the patch works fine. The prompt' window for parameters values is not displayed now. A partner say me that this hotfix is not necessary, but... if this is not applied the window is shown.




    23 Mei 2006 21:07
  • Hi Joe

    I am getting the same parameter prompt of the crystal report viewer in (MS visual studio 2005 .Net Framework 2.0)

    My rpt containes the subreports having the same parameter name as top level main report & I providing the parameter value at runtime. Sometimes it works fine, but manytimes it asks for Parameter and that anoying Parameter Prompt pops up.

    Can post the code to resolve this problem?


    25 Mei 2006 5:45
  • See the link in my previous message to download the hotfix. I never found a completely reliable way to fix this solely in code.
    25 Mei 2006 17:30
  • I have checked the Bussiness Object's solution for the above problem & I have installed that hotpix patch for Crystal Reports for Visual Studio .Net 2005. Still it does not work.
    26 Mei 2006 4:29
  • I also installed the patch with no results. 

    This is how I got my prompting to stop.  I don't know if it's the best way but it works.  It's VB but you get the idea.

                ' Setup the parameter field and value for the report
                Dim pVal As New CrystalDecisions.Shared.ParameterDiscreteValue
                pVal.Value = Me.rtbGeneralVicinity.Text
                Dim pField As New CrystalDecisions.Shared.ParameterField
                pField.Name = "gVicinity" '<-- use the same parameter field name that you used in the report design
                pField.HasCurrentValue =

                ' Setup the report document and data source
                Dim dt As DataTable = dtNotification '<-- must do this because the report needs a plain data table
                Dim pNotificationReport As New rptBurnNotification

                ' Setup the report viewer and show the report to the user
                Dim pReportViewer As New frmReportViewer
                pReportViewer.FMS_CrystalReportViewer.ReportSource = pNotificationReport
                pReportViewer.FMS_CrystalReportViewer.ParameterFieldInfo.Clear() '<-- clears the one we created in design view
                pReportViewer.FMS_CrystalReportViewer.ParameterFieldInfo.Add(pField) '<-- adds the one we created with code

    08 Juni 2006 19:28
  • From my experience also helps if you do some DoEvents (c#), I suppose it prevents the Crystal Reports engine from freacking out :)

    crystalReportViewer1.Visible = true;


    crystalReportViewer1.ReportSource = oRpt;




    27 Juni 2006 15:00
  • Hi Joe,

    It shows the prompt for parameter in crystal report.

    Can you suggest me steps for it?

    I have wrote a code to supply parameters still it is asking for  values thr prompt.

    I am using visual studio 2005.



    28 Juni 2006 17:19
  • Sorry the only thing that I found that would work was the hotfix which I previously posted. I was also building the report using the ReportDocument class and then either setting the ReportSource on the WinForms viewer or the WebForms viewer to that ReportDocument.

    I have since changed to Crystal 11. Too many issues with Crystal for VS 2005 (including a large scalability issue and questionable support commitments by Business Objects).

    In fact, right now I'm using Crystal 11 with VS 2003 since Crystal 11 R2 had bugs when it was shipped (imagine that, Crystal Reports... buggy?).

    So far it has been pretty stable, they put out one hotfix for problems that I was having with R2 but I haven't been willing to go back to it yet. Not an issue since my app uses .Net 1.1 right now. I'll revisit it sometime in the future. Hopefully then they'll have most of the bugs worked out... hopefully.

    29 Juni 2006 4:25
  • Hi JoeBlow,

    I tried that fix.Thanks for that .

     But It takes only one  parameter but does not work for multiple parameters.

    I have more than one 10 parameters to pass.

    Could you please guid me for the same?

    thanks a lot.


    29 Juni 2006 20:46
  • Here is an excerpt of the code that I am using. The parameters are handled by the web page and are already parsed and stored in the parent class's (Dictionary)_rp.ReportParameters

    (_rp is a custom class containing report parameters and database connection information, I haven't included it because it contains specific corporate implementations on how we establish that information) field before this method is called to retrieve the ReportDocument.

     You will also notice that the method receives an already loaded ReportDocument, this is done in a parent method which is part of the parent class (once again, not included because it has some very corporate specific ways of doing things). That method 'CreateReport' may either load the report from the file or load it from the application cache or load it from the session cache. Either way, when the method below is called the report definition has already been loaded, the parent class's parameters Dictionary has already been initialized with values and the parent class's connection information has already been initilialized.

    While testing, I essentially used the same code for both a web viewer and a winforms viewer to retrieve the ReportDocument and then set the viewer.ReportSource to that ReportDocument.

     Note:this code was based on sample code obtained from the Business Objects samples. Some changes have been made where necessary to get it to work (original code did not set the table location properly or failed if the location was not a multi-part name). Also note that since we use MSSQL exclusively some of the connection information is not generic. i.e. crConnInfo.Type = ConnectionInfoType.SQL;

    private ReportDocument getReport(ReportDocument repDoc)
    	ReportDocument subRepDoc = new ReportDocument();
    	Sections crSections;
    	ReportObjects crReportObjects;
    	SubreportObject crSubreportObject;
    	Database crDatabase;
    	Tables crTables;
    	TableLogOnInfo crLogOnInfo;
    	ConnectionInfo crConnInfo = new ConnectionInfo();
    	string reportpath = _rp.ReportPath;
    	string dbuser = _rp.DatabaseUser;
    	string dbpwd = _rp.DatabasePassword;
    	string dbname = _rp.DatabaseName;
    	string dbserver = _rp.DatabaseServer;
    	for (int x = 0; x < _rp.ReportParameters.Count(); x++)
    		repDoc.SetParameterValue(x, _rp.ReportParameters[x].ToString());
    	crDatabase = repDoc.Database;
    	crTables = crDatabase.Tables;
    	foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
    		crConnInfo.ServerName = dbserver;
    		crConnInfo.DatabaseName = dbname;
    		crConnInfo.UserID = dbuser;
    		crConnInfo.Password = dbpwd;
    		crConnInfo.Type = ConnectionInfoType.SQL;
    		crConnInfo.AllowCustomConnection = true;
    		crLogOnInfo = crTable.LogOnInfo;
    		crLogOnInfo.ConnectionInfo = crConnInfo;
    		crTable.Location = "dbo." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") > 0 ? crTable.Location.LastIndexOf(".") + 1 : 0);
    	crSections = repDoc.ReportDefinition.Sections;
    	foreach (Section crSection in crSections)
    		crReportObjects = crSection.ReportObjects;
    		foreach (ReportObject crReportObject in crReportObjects)
    			if (crReportObject.Kind == ReportObjectKind.SubreportObject)
    				crSubreportObject = (SubreportObject)crReportObject;
    				subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
    				crDatabase = subRepDoc.Database;
    				crTables = crDatabase.Tables;
    				foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
    					crConnInfo.ServerName = dbserver;
    					crConnInfo.DatabaseName = dbname;
    					crConnInfo.UserID = dbuser;
    					crConnInfo.Password = dbpwd;
    					crConnInfo.Type = ConnectionInfoType.SQL;
    					crConnInfo.AllowCustomConnection = true;
    					crLogOnInfo = crTable.LogOnInfo;
    					crLogOnInfo.ConnectionInfo = crConnInfo;
    					crTable.Location = "dbo." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") > 0 ? crTable.Location.LastIndexOf(".") + 1 : 0);
    	return repDoc;
    30 Juni 2006 12:54
  • To get rid of that stupid error when looping through the parameters and setting their current values, check to make sure the ReportName property of the parameter equals "".

    Anything other that an empty string means the parameter belongs to a subReport and is probably linked.


    Here's my check:


    if (ParamToFill.ReportName != "")



    11 Juli 2006 6:11
  • I don't know if this will work for your project but I change ReportSource property of the CrystalReportViewer to None and I stopped get the parameter prompt.
    25 Januari 2007 14:38
  • I resolved this issue by installing the stated hotfix and using unique command names within the crystal report. So the main reports command name should be different from the subreport command name.


    • Disarankan sebagai Jawaban oleh YewJin 02 Juli 2009 11:54
    31 Oktober 2007 17:34
  • Thanks Joe

    The patch worked great. We have CR10 with VB Net 2005 and have a function that uses parameters to populate both stored procedures and views for CR and we were also getting the screen that requested us to enter parameters. That request went away after the patch. I did not even have to rebuild my pointers. All life should work this well.


    Glenn Gentile
    10 Juli 2008 19:21
  • I was able to download this patch...however, the readme.txt file had additional links to each fix. These additional links were bogus. Did anyone get there apps to work without the additional link files?
    16 Juli 2008 20:39
  • I kept getting the annoying prompt when all I was trying to do was pass two parameters to a single level Crystal v10 report from VS 2005.

    The hotfix didn't work for me, but reinitiating my ParameterField and ParameterDiscreteValue objects after setting each of the required parameters finally solved the problem:

    This block of code receives the number of parameters to add, the parameter names and parameter values on the querystring. The objects are reinitiated after adding each parameter to the parameters collection.

     Dim parameters As New ParameterFields
            Dim param As ParameterField
            Dim paramvalue As ParameterDiscreteValue

            For lp As Byte = 1 To Convert.ToByte(Request.QueryString("paranos"))
                param = New ParameterField
                paramvalue = New ParameterDiscreteValue

                param.Name = Request.QueryString("para" & lp & "name")
                paramvalue.Value = Replace(Request.QueryString("para" & lp & "value"), "_", "&")
                param.HasCurrentValue = True
            CrystalReportViewer1.ParameterFieldInfo = parameters
    06 Nopember 2008 14:48
  • Hey

    This solution has been worked successfully:


    public Form1()




                WindowsApplication9.CrystalReport1 cr = new CrystalReport1();


                crystalReportViewer1.ReportSource = cr;



    So simply I can say u should put a default Value  For the parameter in the crystal report.

    14 Maret 2009 19:34
  •            crParameterDiscreteValue.Value = pValue;
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["pField"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;




    15 April 2009 5:36

    After a few hours reading all these blogs I and doing all what people recomended with no results I noticed one of the posts mentioned assigning the report to the viewer first and then setting the parameters.  This is what worked for ME!!

    My logic was doing all the report stuff and the last steps were assigning the report to the viewer and refreshing the report.

    create report ....
    load report file....
    set parameters....

    crystalReportViewer1.ReportSource = oRpt;

    I changed to

    create report...
    load report, 
    crystalReportViewer1.ReportSource = oRpt;
    set parameters....

    And..   GOOD BYE To the annoying popup.

    10 Juni 2009 14:27
  • this definitely solved my problem. ive searched & tried various solutions but they did not work. im glad i tried changing the command name of my subreports. and i think no need to install the stated hotfix. (im using CRXI, just for info).
    02 Juli 2009 12:00
  • Well, there seems to be sooooo many kinds of solutions to different people..

    But I would suggest to first try this simple solution posted by Anonymouskels.

    It worked for me and it does make sense too. Renaming the command name in the subreport so that it does not get prompted together with the main report!

    02 Juli 2009 12:02
  • So here's something interesting I discovered while migrating some code from VS2003 to VS2005...

    For CR .Net in VS 2003 you have to call SetDataSource BEFORE setting parameters.
    For CR .Net in VS 2008 you have to call SetDataSource AFTER setting parameters.

    It didn't seem to matter which side of the SetParameter call that the ReportSource method was called, but calling SetDataSource in CR .Net in VS 2008 definitely clears any previously set parameters.

    • Disarankan sebagai Jawaban oleh marmoset 23 September 2009 14:05
    23 September 2009 14:05
  • Hey ! thanks ..Indeed this works , simple solution and effective. Need not go the ParameterField route.
    13 Oktober 2009 23:34
  • Okay this plagued me for EVER!

    I have finally found a solution that actually works!

    You are doing everything right above... in terms of mapping the login credentials to each table & section in the sub reports... however what you are doing wrong is that you are setting the parameter both the main report and the sub report and you can't do that... hence the error "Operation illegal on linked parameter"

    The linking occurs in the report itself and all we need to do is set the main reports parameters... not the main and sub reports. ReportDocument.setParameter is not the right method to use!!!

    So here is the code that worked for me:

    protected void Page_Load(object sender, EventArgs e)
    CrystalDecisions.Web.Parameter p = new CrystalDecisions.Web.Parameter();
            p.Name = "@Parameter1";
            p.DefaultValue = Session["Parameter1"].ToString();
            // Create the connection object
            ConnectionInfo connectionInfo = CreateConnection(Session["DataSource"].ToString(), Session["InitialCatalog"].ToString(), Session["UID"].ToString(), Session["PWD"].ToString());
            // Set the connection info on each table in the report        
            SetDBLogonForSubreports(connectionInfo, CrystalReportSource1.ReportDocument);
            SetDBLogonForReport(connectionInfo, CrystalReportSource1.ReportDocument);
            CrystalReportViewer1.ReportSource = CrystalReportSource1.ReportDocument;
      private static void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
          foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDocument.Database.Tables)
            TableLogOnInfo tableLogonInfo = table.LogOnInfo;
            tableLogonInfo.ConnectionInfo = connectionInfo;
      private static void SetDBLogonForSubreports(ConnectionInfo connectionInfo, ReportDocument reportDocument)
          foreach (Section section in reportDocument.ReportDefinition.Sections)
            foreach (ReportObject reportObject in section.ReportObjects)
              if (reportObject.Kind == ReportObjectKind.SubreportObject)
                SubreportObject subreportObject = (SubreportObject)reportObject;
                ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
                SetDBLogonForReport(connectionInfo, subReportDocument);
      private static ConnectionInfo CreateConnection(string Server, string ServerNamespace, string Username, string Password)
        ConnectionInfo connectionInfo = new ConnectionInfo();
        string connString = "DRIVER={SQL Server};SERVER=" + Server + ";DATABASE=" + ServerNamespace + ";UID=" + Username + ";PWD=" + Password; 
        connectionInfo.Attributes.Collection.Add(new NameValuePair2(DbConnectionAttributes.CONNINFO_DATABASE_DLL, DbConnectionAttributes.DATABASE_DLL_CRDB_ODBC));
        connectionInfo.Attributes.Collection.Add(new NameValuePair2(DbConnectionAttributes.QE_DATABASE_NAME, ServerNamespace));
        connectionInfo.Attributes.Collection.Add(new NameValuePair2("QE_DatabaseType", "ODBC (RDO)"));
        DbConnectionAttributes attributes = new DbConnectionAttributes();
        attributes.Collection.Add(new NameValuePair2(DbConnectionAttributes.CONNINFO_CONNECTION_STRING, connString));
        attributes.Collection.Add(new NameValuePair2("Server", Server));
        attributes.Collection.Add(new NameValuePair2("UseDSNProperties", false));
        connectionInfo.Attributes.Collection.Add(new NameValuePair2(DbConnectionAttributes.QE_LOGON_PROPERTIES, attributes));
        connectionInfo.Attributes.Collection.Add(new NameValuePair2(DbConnectionAttributes.QE_SERVER_DESCRIPTION, Server));
        connectionInfo.Attributes.Collection.Add(new NameValuePair2("QE_SQLDB", true));
        connectionInfo.Attributes.Collection.Add(new NameValuePair2(DbConnectionAttributes.CONNINFO_SSO_ENABLED, false));
        connectionInfo.IntegratedSecurity = false;
        connectionInfo.UserID = Username;
        connectionInfo.Password = Password;
        connectionInfo.ServerName = Server;
        connectionInfo.DatabaseName = ServerNamespace;
        connectionInfo.Type = ConnectionInfoType.CRQE;
        return connectionInfo;

    21 Mei 2011 10:52
  • I was facing the same problem even i was setting the default parameter 

    myRpt.SetParameterValue(0, vatPercent);


    I investigate into matter and found that this prompt comes when you refresh the report.

    So i stop refreshing my report in code(After setting parameter and data source)And it is working fine,

    17 Juni 2011 11:06