Author |
Message |
vlntine82
Newbie
Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
|
Topic: stronly typed reports Posted: 05 Dec 2006 at 12:46pm |
I recently bought the Crystal Reports book and find most of it useful; however, there is one area I am still having trouble. My project consists of retrieving data from a database and then passing it to an existing report and then displaying the report in a webpage. The book mentions that if you use a strongly typed report, you can create an instance of your report in your .NET code like the following: Dim myReport as ReportName.
I have included my reports in my project but can not figure out how to do this. Does anyone know how to get this to work?
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 05 Dec 2006 at 1:12pm |
If you are using ASP.NET, strongly typed reports are no longer in the CR 2005 function set. I talked to the people at Business Objects and they confirmed that for now it is not available. Instead, you have to create a generic ReportDocument object and use the Load() method to read in the report definition from the external .RPT file.
|
IP Logged |
|
vlntine82
Newbie
Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
|
Posted: 05 Dec 2006 at 1:46pm |
thanks for the update
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 05 Dec 2006 at 1:57pm |
Oh yeah - if you are upgrading from a Crystal Reports 2003 application, then you can still use strongly typed-reports for the reports that were already built. This is because the report classes created behind the scenes are still there and get upgraded. But when you create new reports in Crystal Reports 2005, then those classes don't get created and you have to use the Load() method.
HTH.
|
IP Logged |
|
vlntine82
Newbie
Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
|
Posted: 05 Dec 2006 at 2:11pm |
I am creating an application from scratch in VS 2005. I have the following code:
Dim crDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim da As System.Data.OleDb.OleDbDataAdapter = New
crDoc.load("D:\ADNLive\apcnet\" & reportname)
System.Data.OleDb.OleDbDataAdapter(tempSQL, oConn)
myDataset = New System.Data.DataSet
da.Fill(myDataset, "Table1")
myDataset.WriteXmlSchema("D:\ADNLive\apcnet\temp.ds")
crDoc.SetDataSource(myDataset)
CrystalReportViewer1.ReportSource = crDoc
On the line crDoc.SetDataSource(myDataset) I am getting an error saying:
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Invalid report file path.
If I comment this line out, the report loads but without the data.
Any ideas on what could cause this?
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 05 Dec 2006 at 3:17pm |
Your code looks ok.
The error seems to appear when trying to pull the data from the connection? Not sure. Make sure your connection string is valid. Go into debug mode and check that there is data in the DataSet. I also wonder if the dataset path saved in the report is pointing to an invalid file? When it trys to open the dataset, something is triggering to say that it can't find a file.
I've seen some common problems when linking the XML file to the crystal report. Some things to think about:
1) You only need to call WriteXmlSchema() once before you build the report. 2) Build the report using the temp.ds file. 3) DO NOT make ANY changes to the dataset's schema. None. If you have to, you then need to go back into the report's design mode and connect it to the new schema file. 4) Make sure that the table name, "Table1" matches the table name that the report is expecting the dataset to have. Try not passing the table name as well and see what happens (that helps on occaision).
HTH
|
IP Logged |
|
|