Export all Files in PDF Format at a Time using C#

  1. public void updatestaus(string F)  
  2. {  
  3.     sc.Close();  
  4.     sc.Open();  
  5.     SqlCommand cmd = new SqlCommand("update BOND_REG set status='P' where fliono='" + F + "'", sc);  
  6.     cmd.ExecuteNonQuery();  
  7.     sc.Close();  
  8. }  
  9. protected void Button2_Click(object sender, EventArgs e)  
  10. {  
  11.     sc.Open();  
  12.     SqlCommand cmd = new SqlCommand("select Fliono from BOND_REG where status='A'", sc);  
  13.     SqlDataReader SDR = cmd.ExecuteReader();  
  14.     while (SDR.Read() == true) {  
  15.         string St = SDR.GetValue(0).ToString();  
  16.         //SDR.Close();  
  17.         // SDR.Dispose();  
  18.         fileexport(St);  
  19.         updatestaus(St);  
  20. }  
  21. SDR.Close();  
  22. sc.Close();  
  23. }  
  24. public void fileexport(string st1)  
  25. {  
  26.     // SDR.Close();  
  27.     SqlCommand cmd1 = new SqlCommand("select * from BOND_REG where status='A' and Fliono='" + st1 + "'", sc);  
  28.     SqlDataAdapter da = new SqlDataAdapter();  
  29.     da.SelectCommand = cmd1;  
  30.     DataTable datatable = new DataTable();  
  31.     da.Fill(datatable);  
  32.     ReportDocument crystalReport = new ReportDocument();  
  33.     crystalReport.Load(Server.MapPath("~/bond.rpt"));  
  34.     crystalReport.SetDataSource(datatable);  
  35.     ExportOptions rptExportOption;  
  36.     DiskFileDestinationOptions rptFileDestOption = new DiskFileDestinationOptions();  
  37.     PdfRtfWordFormatOptions rptFormatOption = new PdfRtfWordFormatOptions();  
  38.     string reportFileName = @  
  39.     "C:\pdfd\ st1.pdf";  
  40.     rptFileDestOption.DiskFileName = reportFileName;  
  41.     rptExportOption = crystalReport.ExportOptions;   
  42.     {  
  43.         rptExportOption.ExportDestinationType = ExportDestinationType.DiskFile;  
  44.         rptExportOption.ExportFormatType = ExportFormatType.PortableDocFormat;  
  45.         rptExportOption.ExportDestinationOptions = rptFileDestOption;  
  46.         rptExportOption.ExportFormatOptions = rptFormatOption;  
  47.     }  
  48.     crystalReport.Export();  
  49. }