Posted by a ceTe Software moderator
Hello,
You can create a PDF report, using a DataTable. You will need to add the DataTableReportData to the NameValueLayoutData. The DataTableReportData should be added with the DataTable retrieved from the Database. Below is a code sample to create a PDF report using version 10 of DynamicPDF ReportWriter.
Please note that, you will need to set the DataName for the Details section (DLEX file) accordingly with the Key name specified in the Add method of NameValueLayoutData.
static void Main(string[] args)
{
DocumentLayout report = new DocumentLayout(@"Mydocument.dlex");
NameValueLayoutData layoutData = new NameValueLayoutData();
layoutData.Add("Invoice", RetriveSqlOrderReportData());
Document document = report.Layout(layoutData);
document.Draw("MyDocument.pdf");
}
private static DataTableReportData RetriveSqlOrderReportData()
{
SqlConnection con = new SqlConnection(@"Add a valid connection string");
con.Open();
SqlCommand cmd = new SqlCommand("Sql query to retrieve the data", con);
SqlDataReader reader = cmd.ExecuteReader();
DataTable table = new DataTable("Invoice");
table.Load(reader);
return new DataTableReportData(table);
}
Thanks,
ceTe Software Support Team