Pleaseeeeee Help -- Bind ReportSource to CrystalReportViewer (VS.net2003 C# - Crystal Reports)

Posted on 2004-11-30
Last Modified: 2008-01-09
I need to bind a reportsource (already created .rpt), to a CrystalReportViewer. Programs:(VS.net2003 C# - Crystal Reports)
I have already read and followed the msdn instructions, but I think I am just in a panic.  I cannot seem to make this work.  
I started a new web project by using Asp.Net.WebApplication.  I now have forms Webform1.aspx and it's partner .cs.  I have added "Projects.rpt" to the project.  Webform1 now has the CrystalReportViewer, and I used the drag and drop for the oracleConnection.  How do I bind the Projects.rpt to the viewer?

The error I get is this:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1010: Newline in constant

Source Error:


Line 12:       <body MS_POSITIONING="GridLayout">
Line 13:             <form id="Form1" method="post" runat="server">
Line 14:                   <CR:CRYSTALREPORTVIEWER id="CrystalReportViewer1" style="Z-INDEX: 101; LEFT: 80px; POSITION: absolute; TOP: 64px"
Line 15:                         runat="server" Height="1089px" Width="1030px" ReportSource='<%# C:\\Inetpub\\wwwroot\\NOV30_IMPACT\\Projects.rpt" %>' HasRefreshButton="True">
Line 16:                   </CR:CRYSTALREPORTVIEWER></form>

Source File: c:\inetpub\wwwroot\NOV30_IMPACT\WebForm1.aspx    Line: 14

It looks to me like I have the databinding language wrong.  I could really use some help here.  I am in a real bind! (No pun intended)
Question by:NeedInput
    LVL 6

    Expert Comment

    Hi NeedInput,

    I think ReportSource='<%# C:\\Inetpub\\wwwroot\\NOV30_IMPACT\\Projects.rpt" %>'
    should be ReportSource="C:\Inetpub\wwwroot\NOV30_IMPACT\Projects.rpt"

    LVL 20

    Accepted Solution

    I would say:




    LVL 6

    Expert Comment

    if it is in the html/ markup you have to use ReportSource="C:\Inetpub\wwwroot\NOV30_IMPACT\Projects.rpt"
    if it is in C# syntax theAvenger is right


    Author Comment

    I tried the Avenger's suggestion to use: CrystalReportViewer1.ReportSource = @"C:\Inetpub\wwwroot\NOV30_IMPACT\Projects.rpt";

    This at least got a different error.  Now the error is about the logon.  I have the logon listed in the "InitializeComponent" section, so maybe I have put the reportsource in the wrong place.  I put the report source in "private void Page_Load".  I have the connection that requires the logon associated with the report viewer.  Should I have put the reportsource somewhere else?
    LVL 20

    Expert Comment

    No, it's not a problem of the place where you set the report source. What kind of logon does it require? Is it for the database? If so, the report cannot take the needed data because of different reasons. The most probable problem is that the ASPNET account (under which the IIS is running) does not have permissions on the database server

    Author Comment

    I made sure the properties under IIS for this folder were shared and had read and write permissions.  However, I still get an error.  In moving the report source to be after the passwords, I no longer get the logon error, but get an error that page will not load.  This is the code.  Maybe in seeing the whole thing, you might see what I am not seeing.

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using Oracle.DataAccess.Client;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.Web;
    using CrystalDecisions.CrystalReports;
    using CrystalDecisions.Web.Services.Enterprise;
    using CrystalDecisions.ReportSource;

    namespace NOV30_IMPACT

          public class WebForm1 : System.Web.UI.Page
                protected System.Data.OracleClient.OracleConnection oracleConnection1;
                protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
                #region Web Form Designer generated code
                override protected void OnInit(EventArgs e)
                      this.CrystalReportViewer1.Visible = true;
                      this.CrystalReportViewer1.ReportSource= @"C:\Inetpub\wwwroot\NOV30_IMPACT\Projects.rpt";
                private void InitializeComponent()
                      this.oracleConnection1 = new System.Data.OracleClient.OracleConnection();
                      // oracleConnection1
                      this.oracleConnection1.ConnectionString = "user id=user1;data source=ORACLEFILES;password=guest";
                      //      this.Load += new System.EventHandler(this.Page_Load);
                      this.CrystalReportViewer1.Visible = true;
                      this.CrystalReportViewer1.ReportSource = @"C:\Inetpub\wwwroot\NOV30_IMPACT\Projects.rpt";
    LVL 20

    Expert Comment

    It's a problem in the database you are using (oracle if I see correctly), not in the folders. You should add rights for the ASPNET user in the database and all tables, stored procedures and other db objects taht are needed for the report.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now