Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with ReportSource

Status
Not open for further replies.

mlang11

Programmer
Nov 27, 2002
5
CA
Hi, I am new to Crystal Reports. I can not view my crystal report thru the browser. I see this message in a box where the report should be:

CrystalReportViewer - CrystalReportViewer1
User ReportSource or Databindings property to specify a report source.

I have created an .rpt file that is connected to one of my database tables (I used the Database Expert tool - OLE DB ADO connection). I added the CrystalReportViewer control to my form. In the properties for the CrystalReportViewer, I have added the DataBinding (Custom Binding Expression = to the path on my C: in double quotes) for the ReportSource. In the aspx.vb form, I have the following code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.DataBind()
End Sub

Am I missing something? I explicitly followed the walkthru steps on an article I found. Any help would be greatly appreciated.
Thanks in advance
 
Try this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.ReportSource = "C:\MyReports\Report.rpt"
CrystalReportViewer1.DataBind()
End Sub
 
I have added that code and it still doesn't work. :( Before your suggestion, I entered the path to the report in the Databind property with no luck either.

Is it possible it is not working because I have not registered Crystal Reports yet? I am not sure how long Visual Studio has been on my work computer but I am sure it has been over a month. And I get a message when using Crystal Reports asking me if I want to register. Unfortunately, the Visual Studio disks are locked in a cabinet and the key holder won't be back from holidays until Jan 6th.

What do you think of the above and do you have any other suggestions?
 
Well, the .Net won't allow you to create a report in its built-in designer, until you register it. But if your report was created in the Crystal Designer outside of .Net, there shouldn't be any problems. Just to give it another test, you can try to set the report source through the Report object. Add the following references to your project:

CrystalDecisions.CrystalReports.Engine
(yoursystemdrive:\program files\common files\crystal decisions\1.0\managed\CrystalDecisions.CrystalReports.Engine.dll)

CrystalDecisions.ReportSource
(yoursystemdrive:\program files\common files\crystal decisions\1.0\managed\CrystalDecisions.ReportSource.dll)

CrystalDecisions.Shared
(yoursystemdrive:\program files\common files\crystal decisions\1.0\managed\CrystalDecisions.Shared.dll)

CrystalDecisions.Web
(yoursystemdrive:\program files\common files\crystal decisions\1.0\managed\CrystalDecisions.Web.dll)

Try this code (it's a C# sample, you'll need to convert it to VB):


using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;

public class TestPage : System.Web.UI.Page
{

protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

private void Page_Load(object sender, System.EventArgs e)
{
ReportDocument oRpt = new ReportDocument();
reportPath = "C:\\Reports\\Report.rpt";
oRpt.Load(reportPath);
CrystalReportViewer1.ReportSource = oRpt;
}
}
 
I have tried you suggestion with no success. I added the references and wrote the VB .NET version of the C# code (see below).

Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Web

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents Label1 As
System.Web.UI.WebControls.Label
Protected WithEvents CrystalReportViewer1 As
CrystalDecisions.Web.CrystalReportViewer

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim reportPath As String
Dim oRpt As New ReportDocument()

reportPath = &quot;C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Reports\General Business\World Sales Report.rpt&quot;
oRpt.Load(reportPath)
CrystalReportViewer1.ReportSource = oRpt

CrystalReportViewer1.DataBind()

End Sub

End Class

The report I am calling is a sample one that came with the installation disks. So I know it is not a data connection problem because there is no data being pulled from a database. The report shows up in designer mode in its entirety, but not in the browser...

The Visual Studio .NET disk are locked in a cabinet that I won't get the keys for until Jan 6th (the earliest). So I will try to register Crystal Reports then and see if I have any success. If you have any more suggestions, I am all ears. :) Thanks for your help so far.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top