Here is my code, it generates a blank PDF file.
private void btnPrint_Click(object sender, EventArgs e)
{
Connection.ConnectionReport();
CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string Query = "Select OPR.Id,OPR.VendorId from OrderPR OPR inner join OrderPOTransaction OT on OPR.Id=OT.OrderPRId " +
"where OPR.CancelTag=0 and OT.CancelTag=0 ";
string Query1 = "Select Distinct VM.VendorName,VM.VendorAddress,VM.City,VM.State,VM.Country,VM.PinCode," +
"ContactNumber from VendorMaster VM inner join OrderPR OP on VM.Id=OP.VendorId "+
"where VM.CancelTag=0 and OP.CancelTag=0 ";
string Query2 = "Select OT.EquipmentId,OT.Qty,OT.UOM,OT.Rate," +
"OT.Amount from OrderPOTransaction OT inner join OrderPR OP on OT.OrderPRId=OP.Id " +
"where OP.CancelTag=0 and OT.CancelTag=0 ";
string Query3 = "Select TermsAndConditions as 'General Terms and Conditions:',TestingInspectionAndGuarantees as 'Testing,Inspection and Gaurantees:',DocumentsToBeSubmitted as 'Documentation:',OtherNotes from OrderPO " +
"where CancelTag=0 ";
SqlCommand cmd = new SqlCommand(Query, Connection.DBconnection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.SelectCommand = cmd;
cmd.CommandText = Query;
DataSet1 ds = new DataSet1();
da.Fill(ds,"OrderPRDS");
da.Dispose();
SqlCommand cmd1 = new SqlCommand(Query1, Connection.DBconnection);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.SelectCommand = cmd1;
cmd1.CommandText = Query1;
DataSet1 ds1 = new DataSet1();
da1.Fill(ds1,"VendorDS");
da1.Dispose();
SqlCommand cmd2 = new SqlCommand(Query2, Connection.DBconnection);
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
da2.SelectCommand = cmd2;
cmd2.CommandText = Query2;
DataSet1 ds2 = new DataSet1();
da2.Fill(ds2, "OrderPOTransactionDS");
da2.Dispose();
SqlCommand cmd3 = new SqlCommand(Query3, Connection.DBconnection);
SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
da3.SelectCommand = cmd3;
cmd3.CommandText = Query3;
DataSet1 ds3 = new DataSet1();
da3.Fill(ds3, "OrderPODS");
da3.Dispose();
CrystalReport1 crystalReport = new CrystalReport1();
crystalReport.SetDataSource(ds);
crystalReport.SetDataSource(ds);
crystalReport.SetDataSource(ds1);
crystalReport.SetDataSource(ds2);
crystalReport.SetDataSource(ds3);
crystalReport.Load();
rd.Load(@"D:\Rhul Gadhe\SEApplication\SEApplication\CrystalReport1.rpt");
rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\Report.pdf");
rd.PrintToPrinter(2, true, 1, 2);
MessageBox.Show("Exported Successful");
}
}
}