I am creating a simple report using the .NET object from my project as a data source using a method SetDatasource(). However, when I run the report, I get the error "Error logging into the database." This report does not connect to the database at all - did I miss something?
Thanks a lot, D.
ADDED: I think this will help if I enable the Controller action. This is a quick and dirty test, not what the last method will look like:
public ActionResult StewardSheets(int showId, int groupId)
{
ReportClass rptH = new ReportClass();
rptH.FileName = DataHelper.getReportFilePath("Test.rpt",this);
NZDSDataContext dataContext = new NZDSDataContext();
var showDetails = (from s in dataContext.Shows
where s.ID == showId
select new StewardSheetModel
{
EventDate = s.EventDate.ToLongDateString(),
Region = s.Region.Name,
ShowTitle = s.Name
}).FirstOrDefault();
List<StewardSheetModel> details = new List<StewardSheetModel>();
details.Add(showDetails);
rptH.SetDataSource(details);
rptH.Load();
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
}
FIXED: D'o! I used ReportClass instead of ReportDocument. This line has been changed, and also use Refresh () since Load () is not a valid method. Now it works great!