hi everyone
i made crystal report then i saved it as a word document but i passed parameters to that report then an error occured after that
the error is:-
missing parameter values ok
i tried to save it with 2 different codes but th same error shows up

the first code is:-

CrystalReport1 wordreport = new CrystalReport1();
filename = saveFileDialog1.FileName;
ExportOptions op = new ExportOptions();
            op.ExportDestinationType = ExportDestinationType.DiskFile;
            op.ExportFormatType = ExportFormatType.WordForWindows;
            DiskFileDestinationOptions dfdo = new DiskFileDestinationOptions();
            dfdo.DiskFileName = filename;
            op.ExportDestinationOptions = dfdo;
wordreport.Export(op); -----------------------here i get the error
            dfdo = null;
            wordreport = null;
the other code:-
CrystalReport1 wordreport = new CrystalReport1();
filename = saveFileDialog1.FileName;
 wordreport.ExportToDisk(ExportFormatType.WordForWindows, filename);---------------here i get the error
            wordreport.SetDataSource(dataReport);
wordreport = null;

can anybody help plz

Be sure to use code tags because it makes it easier to read the code.

You are not passing in any parameters to the report in the code you gave. What are the names of the parameters defined in the report and what are their types?

You are not passing in any parameters to the report in the code you gave. What are the names of the parameters defined in the report and what are their types?

        CrystalReport1 myDataReport = new CrystalReport1();
        myDataReport.SetDataSource(dataReport);

        ParameterFieldDefinition paramField;
        ParameterValues currentValues;

        ParameterDiscreteValue p2;

        paramField = myDataReport.DataDefinition.ParameterFields["@Id"];

        p2 = new ParameterDiscreteValue();            
        string s1;
        s1 = tak.ToString();
        p2.Value = s1;
        currentValues = paramField.CurrentValues;
        currentValues.Add(p2);
        paramField.ApplyCurrentValues(currentValues);
        /*********************************************************************************/

        paramField = myDataReport.DataDefinition.ParameterFields["@ky"];
        p2 = new ParameterDiscreteValue();
        s1=dgv.Rows[1].Cells[0].Value.ToString();
        p2.Value = s1                   ;
        currentValues = paramField.CurrentValues;
        currentValues.Add(p2);
        paramField.ApplyCurrentValues(currentValues);
        crystalReportViewer1.ReportSource = myDataReport;
CrystalReport1 myDataReport = new CrystalReport1();
myDataReport.SetParameterValue("para_name", "value");
myDataReport.SetDataSource(dataReport);
CrystalReport1 myDataReport = new CrystalReport1();
myDataReport.SetParameterValue("para_name", "value");
myDataReport.SetDataSource(dataReport);

actually the same error is still showing up i don't think that the error in the way in assigning values to the parameters it's in the way of saving the report in that statement:-

wordreport.ExportToDisk(ExportFormatType.WordForWindows, filename);

or in the other implementing way:-

ExportOptions op = new ExportOptions();
            op.ExportDestinationType = ExportDestinationType.DiskFile;
            op.ExportFormatType = ExportFormatType.WordForWindows;
            DiskFileDestinationOptions dfdo = new DiskFileDestinationOptions();
            dfdo.DiskFileName = filename;
            op.ExportDestinationOptions = dfdo;
            //wordreport.ExportToDisk(ExportFormatType.WordForWindows, filename);
            wordreport.SetDataSource(dataReport);
            wordreport.Export(op); ----------------here
            dfdo = null;
            wordreport = null;

Is it possible you have subreports in your report that have missing parameter links?

Try adding the following code statement and see if it shows any unforeseen parameters:

foreach (ParameterFieldDefinition parafld in wordReport.DataDefinition.ParameterFields)
            {
            }// set breakpoint and examine parafld

Is it possible you have subreports in your report that have missing parameter links?

Try adding the following code statement and see if it shows any unforeseen parameters:

foreach (ParameterFieldDefinition parafld in wordReport.DataDefinition.ParameterFields)
            {
            }// set breakpoint and examine parafld

actually i did set breakpoint and examined parafld and there are no unforeseen parameters

Are you using subreports in the report?

actually iam not using subreports
but when i try to export the report to word document without using my code it exported the report including the parameters in it normally but the arabic data are reversed can anybody help about that

CrystalReport1 myDataReport = new CrystalReport1();
myDataReport.SetParameterValue("para_name", "value");
myDataReport.SetDataSource(dataReport);
----------------------------------------------------------------------------
CrystalReport1 myDataReport = new CrystalReport1();
myDataReport.SetParameterValue("para_name", "null" );
myDataReport.SetDataSource(dataReport);

how to set parameter values null.. because i use this code..crystal report the result is blank.. thx

Hi hiks but actually i think that when you upload your program the error will be much more obvious

FYI - in case this wasn't resolved.

You have to set the datasouce FIRST, then the parameters. Otherwise it throws that error.

ok thanks a lot
appreciated

ok thanks a lot
appreciated

My pleasure. This was one of the odd errors that is extremely hard to trace down. Fortunately, I had 2 paths; one worked one didn't. Made it easier to dissect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.