Click here to Skip to main content
15,889,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hai all
i am building a website using asp.net4.0 and c#4.0,backend is Sql server2008.
when iam trying to execute the following code an error below is generated.
Code:
C#
protected void bt_rep0_Click(object sender, EventArgs e)
    {
        string sql;
        sql = "SELECT m.[proj_ID] ,pt.[proj_type_ff],m.[proj_no],m.[proj_prop_no],m.[Proj_title],pr.[investigator_name], pa.[investigator_name],fa.[fund_agency_acronym],m.[Budg],m.[from_date],m.[close_date],pe.[ext_date],m.[RptNo],m.[status] FROM [monitor].[dbo] .[MENU] m LEFT OUTER JOIN [monitor].[dbo].[pro_investigator] pr ON m.[investgator_id] = pr.[investgator_id] LEFT OUTER JOIN [monitor].[dbo] .[project_type] pt ON m.[proj_type_id]  = pt.[proj_type_id] LEFT OUTER JOIN [monitor] .[dbo] .[project_AItable] pa on m.[proj_ID] = pa.[proj_ID] LEFT OUTER JOIN [monitor].[dbo].[project_FAtable] pf on m.[proj_ID] = pf.[proj_ID] LEFT OUTER JOIN [monitor] .[dbo] .[fund_agency] fa on pf.[fund_agency_id] = fa.[fund_agency_id] LEFT OUTER JOIN [monitor] .[dbo] .[project_ext] pe on m.[proj_ID] = pe.[proj_ID] order by m.[proj_ID] ";

        c27.cmd = new System.Data.SqlClient.SqlCommand(sql, c27.connect());
        c27.da = new System.Data.SqlClient.SqlDataAdapter(sql, c27.connect());
        c27.da.Fill(c27.ds);
        c27.da.Fill(c27.ds, "ss");
        //MessageBox.Show(c27.ds.Tables[1].Rows.Count.ToString());


       //crystalr
        CrystalReport1 objRpt = new CrystalReport1();//error generating code
        objRpt.SetDataSource(c27.ds.Tables[1]);
        CrystalReportViewer1.ReportSource = objRpt;

        ////////////CrystalReportViewer1;
        ////////////crystalReportViewer1.Refresh();
    }


Error Statement :
Error 48 The type or namespace name 'CrystalReport1' could not be found (are you missing a using directive or an assembly reference?)


can any help me to get out from this error
thanks in advance.
Posted
Updated 25-Aug-21 3:27am
Comments
Ragi Gopi 25-Apr-12 6:01am    
Can Any one plz help
[no name] 25-Apr-12 6:56am    
Patience. The site is mostly volunteers. You will get an answer when you get an answer.

The error is very clear. I am not familiar with crystal reports but the error is telling you that it can't find the "CrystalReport1" namespace that you specified. Are you sure that it's not just "CrystalReports"? You need to specify the correct namespace or reference the assembly that the namespace is located in.
Ragi Gopi 25-Apr-12 7:18am    
ok,thanks

Look here: Similar issue resolved[^]

Based on it, earlier versions did not allow this. In case you are on VS2010, try:
1. Go to Properties of the project
2. Choose Target Framework as .NET Framework 4 (Platform Target as x86 or x64)
 
Share this answer
 
Comments
Ragi Gopi 27-Apr-12 2:18am    
i am working on web application
and using asp.net
then how to set platform target.
Sandeep Mewara 27-Apr-12 2:59am    
Make sure your app is hosted with correct .NET framework. Check the version defined for the AppPool in IIS.

It's a config issue if you have the Crystal installed on server. You need to track that down.
try adding all the references of crystal report to the reference folder on your project. Also add the references to your class like
"
C#
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

"
 
Share this answer
 
Comments
Ragi Gopi 28-Apr-12 3:26am    
i had added all these ...
still not working..
added reference that is needed for crystal reports
 
Share this answer
 
Apparently CrystalReport1 is the default name of the auto generated report. You likely changed the name of the report in the solution explorer like I did and broke the reference.
 
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