George,
I've done Crystal Reports directly off of BO's, although in a Windows Forms app and not a web project.
When I've seen Crystal ask for the database login, it was because I didn't set the data source of the report via .SetDataSource(). I figured Crystal was asking where to get the data because it wasn't handed any.
Not sure if that's your issue though.
Mike
Here's some code I have - never done it in a web app, but I'm guessing it's similar. Hope it helps anyway.
// ReportForm is a windows form that contains a Crystal
// report viewer.
ReportForm rf = new ReportForm();
rf.Text = "Order Report";
// OrderHeaderReport is a Crystal ReportClass.
OrderHeaderReport report = new OrderHeaderReport();
// Set the viewer's report source to our report.
rf.crystalReportViewer1.ReportSource = report;
// Get the data. OrderHeader is a Csla.ReadOnlyListBase.
OrderHeader order = OrderHeader.GetOrderHeader(_orderHeader.PK);
// Set the report's data to our business object.
report.SetDataSource(order);
rf.WindowState = FormWindowState.Maximized;
rf.Show();
Thanks for the steps, the confusion remains I have written the following code
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports
Secretary.LibraryPartial
Class MessagesRPT Inherits System.Web.UI.Page Private messagesReport As New MessagesRPT 'that is the report Dim businessObject As Secretary.Library.Subscriber Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadbusinessObject = Session(
"currentObject")myCrystalReportViewer.ReportSource = messagesReport
//The problem is that the messagesReport does not show the method SetDataSource. Instead it show a private method ob businessobject. That is what confuses me.
End SubEnd
Class
What does "MessagesRPT" derive from? I guess it's not a CrystalDecisions.CrystalReports.Engine.ReportClass?
Oh, I think I've seen this before - does the exception say "The data source object is invalid."?
If that's the case, it could be because you're passing in an object in .SetDataSource() that Crystal doesn't like. I think the Crystal documentation is a little out of whack. Intellisense doesn't show an overload that takes a type of object, but you can pass in any object. The documentation doesn't show that an overload takes a type that implements IEnumerable, but that's what you pass in, so it would have to be a ReadOnlyList or something else that implements IEnumerable.
Even if you have only one object for your report, you need to wrap it in something that implements IEnumerable.
Heh, little late on that last response.
Glad you got it figured out.
Copyright (c) Marimer LLC