locked
Crystal report error(Invalid report file path.) RRS feed

  • Question

  • User1594475756 posted

    hi,

         I wrote below code and while running this am getting error like this " Invalid report file path."

    Please help me

    In aspx.cs:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    using CrystalDecisions.CrystalReports;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using CrystalDecisions.Web;
    using CrystalDecisions.CrystalReports.Design;

    public partial class Default3 : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=naveen;Integrated Security=True");
        SqlCommand cmd;
        SqlDataReader dr;
        
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlDataAdapter da=new SqlDataAdapter ("select * from products where pid='"+TextBox1.Text +"'", con);
            DataSet d = new DataSet();
            da.Fill(d, "products");
            //cmd = new SqlCommand("select * from products where pid='"+TextBox1.Text +"'", con);
            //dr = cmd.ExecuteReader();
            GridView1.DataSource = d;
            GridView1.DataBind();
              con.Close();
            //CrystalReportSource s = new CrystalReportSource();

            ReportDocument r = new ReportDocument();
          //  r.Load(da );
            //r.SetDataSource (d);
    //
           // CrystalReportViewer1.ReportSource = r;// CrystalReportSource2;//GridView1;
            
          // CrystalReportViewer1.DataBind();

           // r.SetDatabaseLogon("Data Source=.;Initial Catalog=naveen;Integrated Security=True", "products");
            CrystalReportViewer1.ReportSource = r;
            CrystalReportViewer1.DataBind();
        }
    }

    In aspx page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="CR" %>
    <%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .style1
            {
                width: 100%;
            }
            .style2
            {
            }
            .style3
            {
                width: 216px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <table class="style1">
           
            <tr>
                <td class="style2" colspan="2">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
                </td>
            </tr>
            <tr>
                <td class="style3">
                    &nbsp;</td>
                <td>
                    <asp:GridView ID="GridView1" runat="server">
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style3">
                    &nbsp;</td>
                <td>
                            <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
                                AutoDataBind="True" GroupTreeImagesFolderUrl="" Height="1202px"
                                ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="1104px" />
                            <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
                                <Report FileName="CrystalReport.rpt">
                                </Report>
                            </CR:CrystalReportSource>
                            </td>
            </tr>
        </table>
        <div>
        
            <CR:CrystalReportSource ID="CrystalReportSource2" runat="server">
                <Report FileName="CrystalReport.rpt">
                </Report>
            </CR:CrystalReportSource>
        
        </div>
        </form>
    </body>
    </html>


    Tuesday, August 16, 2011 1:14 AM

All replies