Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I want to export crystal report in PDF file format.

what i want is i want to create multiple pdf files in loop.

but i am getting error.

first report it creates properly but when in loop to other record it throwing error.

following is my code for that.

C#
while (objReaderRegno.Read())
               {
                   regno = objReaderRegno[0].ToString();
                   staff_Cd = objReaderRegno[1].ToString();

                   ReportDocument rpt = new ReportDocument();
                   objclsReport = new clsReport();

                   int NewVal = Convert.ToInt16(regno);
                   string Path = Server.MapPath("Reports//form12ba_16_217_27a//rep_form12ba.rpt");
                   rpt.Load(Path);
                   rpt = objclsReport.SetReportConnection(rpt);
                   rpt.SetParameterValue("from_dt", "1/4/2009"); //Convert.ToDateTime(txtFromDate12BA.Text).ToString("dd/MMM/yyyy"));
                   rpt.SetParameterValue("p_reg_no", regno);
                   rpt.SetParameterValue("print_date", "1/4/2009"); //Convert.ToDateTime(txtPrintDate12BA.Text).ToString("dd/MMM/yyyy"));

                  // ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.UpdatePanel1.GetType(), "reportshow", "alert('" + regno + "');", true);

                   string FileName = @"d:\testfile\" + "12BA-" + fin_year_subtext + "-" + staff_Cd+".pdf";
                   //rpt.ExportToDisk(ExportFormatType.PortableDocFormat, FileName);
                   rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, FileName);
}


Erro:-

CSS
Invalid Argument provided.
Failed to retrieve data from the database.
Error in File rep_form12ba {62DD9BC1-B7D1-465B-B6DB-A1A091C9D236}.rpt:
Invalid argument for database.
Posted
Updated 25-Feb-11 21:16pm
v4
Comments
Sandeep Mewara 26-Feb-11 1:48am    
What error?
Abhinav S 26-Feb-11 2:04am    
Whats the error?

1 solution

Trying debugging through your code to see where exactly the error occurs and then again in debug mode, check to see if any of these values are null or in an incorrect format.
 
Share this answer
 
Comments
Espen Harlinn 26-Feb-11 10:04am    
Good advice - I'd guess he has hardcoded the connection string somewhere :)

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