First time here? Check out the FAQ!
x

How to bind dataset with Crystal Report in C# Windows application?

0 votes
asked by about Crystal Reports Export To Multiple PDF Files Software
edited by

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");
        }
    }
}

1 Answer

0 votes
answered by (264k points)

Unfortunately, you will have to use the video tutorials and websites listed through Google Search. I have seen that this problem is detailed on various websites. You can get the solution by visiting those websites to see exactly how is the report generated.

Google Search: https://goo.gl/qFK8PU

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...