I am using VS 2015, Crystal Report is also up-to date, SQL Server 2012.
I want to populate the Crystal Report datasource via a viewmodel class and export it to PDF
ReportDocument rptH = new ReportDocument();
rptH.FileName = Server.MapPath("~/reports/InvoiceReportsSample1.rpt");
var showInvoices =
(from ids in context.Invoices
where ids.InvoiceNumber == "01-04-2017-1"
select new Invoice_Report_ViewModel()
{
Invoiceid = ids.Invoiceid,
InvoiceNumber = ids.InvoiceNumber,
CustomerCompanyName = ids.CustomerCompanyName,
FirstBlankSpaceForPanel1 = ids.FirstBlankSpaceForPanel1,
MainDiscount = ids.MainDiscount,
MainTaxes = ids.MainTaxes,
MainTotal = ids.MainTotal,
TypeOfPortals = ids.TypeOfPortals,
TypeOfTickets = ids.TypeOfTickets,
SecondBlankSpaceForPanel2 = ids.SecondBlankSpaceForPanel2,
}).First();
var showInvoiceDetails = (from ids in context.InvoiceDetailses
where
ids.Invoiceid == showInvoices.Invoiceid
select new InvoiceDetails_Report_ViewModel()
{
}).ToList();
var querylist = new List<Invoice_Report_ViewModel> { showInvoices };
rptH.Database.Tables[0].SetDataSource(querylist);
rptH.Database.Tables[0].SetDataSource(showInvoiceDetails);
rptH.Refresh();
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
Please help I get an error
Data source Login Failed
but I am not connecting report to the database and also I have configure report using .NET object
Please help