Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am getting the fallowing error in Crystal reports

C#
Error	1	The type or namespace name 'myreport' could not be found (are you missing a using directive or an assembly reference?)	F:\myaspcrystal\Default.aspx.cs	49	9	F:\myaspcrystal\


C#
Error	3	The name 'crystalReportViewer1' does not exist in the current context	F:\myaspcrystal\Default.aspx.cs	77	9	F:\myaspcrystal\



C#
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Collections.Generic;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;


C#
public partial class _Default : System.Web.UI.Page 
{
    public static string connectionString = "Data Source=FAROOQPC\\SQLEXPRESS; Initial Catalog=mydb; Integrated Security=True";

    private SqlDataAdapter  dataAdapter;
    private DataSet dataSet;
    private DataTable dataTable;

    // *** End ADO.NET objects ***
    private static string Name;
    private static string Cell;
    private static string Address;
    //private static string EmpId;
    protected void Page_Load(object sender, EventArgs e)
    {
        string commandstring = "select * from db";

        // The link between the sql command and the database connection
        dataAdapter = new SqlDataAdapter(commandstring, connectionString);

        // Define insert, update, and delete sql commands to use.
        //    BuildCommands();

        // Declare and fill the in-memory dataset from the database
        dataSet = new DataSet();
        dataSet.CaseSensitive = true;
        dataAdapter.Fill(dataSet, "Employee");


        myreport Report = new myreport(); //error line 1
        
        
        
             
        
        mydataset ds=new mydataset();
        mydataset.DataTable1DataTable t = (mydataset.DataTable1DataTable)ds.Tables[0];

        dataTable = dataSet.Tables[0];


        foreach (DataRow dataRow in dataTable.Rows)
        {
            // Load global strings from column values in the datarow
            //CustId = dataRow[""].ToString().Trim();
            Name = dataRow["Name"].ToString().Trim();
            Cell = dataRow["Cell"].ToString().Trim();
            Address = dataRow["Address"].ToString().Trim();


            t.AddDataTable1Row(Name, Cell, Address);
        }



        Report.SetDataSource(ds);

        crystalReportViewer1.ReportSource = Report;     //Error Line 2            
 
    }
}


any one help me to figure it out
Posted
Updated 2-Oct-11 11:21am
v2
Comments
Ankur\m/ 2-Oct-11 23:48pm    
Is the report part of your application? It seems they are somehow not included in your project.
codegeekalpha 3-Oct-11 6:07am    
its included in my project...
codegeekalpha 3-Oct-11 6:07am    
is dere any framework issue???

Check the name of your CrystalReportViewer whether it is "crystalReportViewer1" or something else.
 
Share this answer
 
Hey,
Replace this 'myreport Report = new myreport();' with
ReportDocument Report = new ReportDocument();

then Assign this 'Report' object to crystalReportViewer1
As given below:-
and make sure you r not using the Class name of report viewer to bind the report
crystalReportViewer1.ReportSource = crystalReport;
 
Share this answer
 
Comments
codegeekalpha 4-Oct-11 19:13pm    
now i am getting erroy can't fine report path
indrish 5-Oct-11 3:22am    
use this
crystalReport.Load(Server.MapPath("CrystalReport1.rpt"));
if u r still getting same problem then tell me exact location where u store the report.
REPLACE YOUR FIRST ERROR LINE BY

ReportDocument crystalReport = new ReportDocument();


REPLACE YOUR SECOND ERROR LINE BY


CrystalReportViewer1.ReportSource = crystalReport;
 
Share this answer
 
Error 1:
In your code there is no Class named "myreport".
Please use ReportDocument class for manipulating crystal report.

Error 2:
You didnt add the CrystalReportViewer control in your design view.
For adding CrystalReportViewer,
Goto ToolBox->Reporting Tab-> CrystalReportViewer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900