Click here to Skip to main content
15,031,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: 'Missing parameter values.'


my code is here
ReportDocument cryRpt = new ReportDocument();
           cryRpt.Load("E:\\Visual Studio\\Al Barkat Project\\bt\\Forms\\Reports\\SalesInvoice.rpt");

           TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
           TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
           ConnectionInfo crConnectionInfo = new ConnectionInfo();
           Tables CrTables;

           crConnectionInfo.ServerName = "MUKHTAR";
           crConnectionInfo.DatabaseName = "RetailPharmacy";
           crConnectionInfo.UserID = "sa";
           crConnectionInfo.Password = "123";

           CrTables = cryRpt.Database.Tables;
           foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
           {
               crtableLogoninfo = CrTable.LogOnInfo;
               crtableLogoninfo.ConnectionInfo = crConnectionInfo;
               CrTable.ApplyLogOnInfo(crtableLogoninfo);
           }

           cryRpt.Refresh();

           cryRpt.PrintToPrinter(1, true, 0, 0);


What I have tried:

ReportDocument cryRpt = new ReportDocument();
           cryRpt.Load("E:\\Visual Studio\\Al Barkat Project\\bt\\Forms\\Reports\\SalesInvoice.rpt");

           TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
           TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
           ConnectionInfo crConnectionInfo = new ConnectionInfo();
           Tables CrTables;

           crConnectionInfo.ServerName = "MUKHTAR";
           crConnectionInfo.DatabaseName = "RetailPharmacy";
           crConnectionInfo.UserID = "sa";
           crConnectionInfo.Password = "123";

           CrTables = cryRpt.Database.Tables;
           foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
           {
               crtableLogoninfo = CrTable.LogOnInfo;
               crtableLogoninfo.ConnectionInfo = crConnectionInfo;
               CrTable.ApplyLogOnInfo(crtableLogoninfo);
           }

           cryRpt.Refresh();

           cryRpt.PrintToPrinter(1, true, 0, 0);
Posted
Updated 8-May-21 21:19pm

We can't tell: we have no access to your report or the data it pertains to.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
   
The exception is thrown because the report expects one ore more parameter values to be passed. In other words, the report layout is configured to ask parameters before the report is run.

You can use ReportDocument.SetParameterValue Method (String,Object) (CrystalDecisions.CrystalReports.Engine) | Microsoft Docs[^] to set the value for each required parameter
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900