I have c# report PDF export project based on a dataTable I have manually created. I am using the following code to try and set the datasource and have tried many different variations but cannot get the information from my database to show up properly in my report exported as PDF. And saving as hard disk of my computer.
But when running the folllowing code, I can't see any PDF being exported. The exception is below
CrystalDecisions.CrystalReports.Engine.LogOnException: Database logon failedSystem.Runtime.InteropServices.COMException: Database logon failed.
I have set two data source , contract , contract members in main report sub report for contract members
one contract can have many contract members.
It occurs at the last line
Any help is greatly appreciated. The below is my code
string result;
ContractReport report = new ContractReport();
ContractDTO source = new ContractDTO();
report.Load(Server.MapPath("~/ContractReport.rpt"));
source.Id = 1;
source.Code = "ABC";
source.Title = "LondonEast";
source.Member = new List<ContractMembersDTO>();
source.Member.Add(new ContractMembersDTO() { Id = 1, ContractId = 1, StaffNameEng = "ABC", Position = "Project Manager" });
source.Member.Add(new ContractMembersDTO() { Id = 2, ContractId = 1, StaffNameEng = "DEF", Position = "Project QS" });
source.Member.Add(new ContractMembersDTO() { Id = 3, ContractId = 1, StaffNameEng = "GHI", Position = "Site Manager" });
report.SetDataSource(new[] { source });
if (reportType.Equals("PDF"))
{
try
{
MemoryStream oStream;
oStream = (MemoryStream)report.ExportToStream(ExportFormatType.PortableDocFormat);