Click here to Skip to main content
15,921,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Even I add namespace like
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
using System.Web.UI.WebControls;


and also add reference
crystaldecision.crystalreport.engine
crystaldecision.shared

I got an error like

Error	2	The type or namespace name 'CrystalReports' does not exist in the namespace 'CrystalDecisions' (are you missing an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	10	24	FB_BILLING
Error	3	The type or namespace name 'Shared' does not exist in the namespace 'CrystalDecisions' (are you missing an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	11	24	FB_BILLING
Error	4	The type or namespace name 'ReportDocument' could not be found (are you missing a using directive or an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	24	9	FB_BILLING
Error	5	The type or namespace name 'Tables' could not be found (are you missing a using directive or an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	25	9	FB_BILLING
Error	6	The type or namespace name 'TableLogOnInfos' could not be found (are you missing a using directive or an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	27	9	FB_BILLING
Error	7	The type or namespace name 'TableLogOnInfo' could not be found (are you missing a using directive or an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	28	9	FB_BILLING
Error	8	The type or namespace name 'ConnectionInfo' could not be found (are you missing a using directive or an assembly reference?)	E:\New folder\Vinay\FB_BILLING\FBB_Reports.cs	29	9	FB_BILLING


My source code like these

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
using System.Web.UI.WebControls;

namespace FB_BILLING
{
    public partial class FBB_Reports : Form
    {

        public static int m_Ids;
        public static string m_Paths;
        public static DataTable m_dt = null;

        ReportDocument cryRpt = new ReportDocument();
        Tables crTables;
        Table crTable;
        TableLogOnInfos crTableLogonInfos;
        TableLogOnInfo crTableLogOnInfo;
        ConnectionInfo crConnectionInfo = new ConnectionInfo();

        public FBB_Reports(int i_Ids, string s_Paths, DataTable dt)
        {
            InitializeComponent();
            m_Ids = i_Ids;
            m_Paths = s_Paths;
            m_dt = dt;

        }

        private void InitializeComponent()
        {
            throw new NotImplementedException();
        }

        private void FBB_Reports_Load(object sender, EventArgs e)
        {
            string sPath = Application.StartupPath;
            Directory.SetCurrentDirectory(sPath);
            if (m_Paths == "Reports/Quotation.rpt")
            {
                PrepareQuatation();
            }
            if (m_Paths == "Reports/InvoiceTotal.rpt")
            {
                PrepareData();

            }
            if (m_Paths == "Reports/InvoiceBill.rpt")
            {
                PrepareInvoice();
            }

            if (m_Paths == "Reports/QuotationBill.rpt")
            {
                PrepareQuotation();
            }
            this.WindowState = FormWindowState.Maximized;
            FBB_Progress objProgress = new FBB_Progress();
            objProgress.Hide();
        }
        private void PrepareInvoice()
        {
            Table crTable;
            Tables crTables;
            string sPath = Application.StartupPath;
            Directory.SetCurrentDirectory(sPath);


            cryRpt.Load(m_Paths);
            crTables = cryRpt.Database.Tables;


            CDBConnectionInfo crDBConnectionInfo = CUtil.GetConnection();
            TableLogOnInfo LogOnInfo = new TableLogOnInfo();
            crConnectionInfo.ServerName = crDBConnectionInfo.ServerName;
            crConnectionInfo.DatabaseName = "FB_Billing";
            crConnectionInfo.UserID = crDBConnectionInfo.UserName;
            crConnectionInfo.Password = crDBConnectionInfo.Password;
            crConnectionInfo.IntegratedSecurity = crDBConnectionInfo.IntegratedAuth;
            foreach (Table crTable_loopVariable in crTables)
            {
                crTable = crTable_loopVariable;
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }

            cryRpt.SetParameterValue("@INVOICE_MASTER_ID", m_Ids);
            xcrvReports.ReportSource = cryRpt;
        }
        private void PrepareQuotation()
        {
            Table crTable;
            Tables crTables;
            string sPath = Application.StartupPath;
            Directory.SetCurrentDirectory(sPath);


            cryRpt.Load(m_Paths);
            crTables = cryRpt.Database.Tables;


            CDBConnectionInfo crDBConnectionInfo = CUtil.GetConnection();
            TableLogOnInfo LogOnInfo = new TableLogOnInfo();
            crConnectionInfo.ServerName = crDBConnectionInfo.ServerName;
            crConnectionInfo.DatabaseName = "FB_Billing";
            crConnectionInfo.UserID = crDBConnectionInfo.UserName;
            crConnectionInfo.Password = crDBConnectionInfo.Password;
            crConnectionInfo.IntegratedSecurity = crDBConnectionInfo.IntegratedAuth;
            foreach (Table crTable_loopVariable in crTables)
            {
                crTable = crTable_loopVariable;
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }

            cryRpt.SetParameterValue("@QUOTATION_MASTER_ID", m_Ids);
            xcrvReports.ReportSource = cryRpt;
        }
        private void PrepareData()
        {
            cryRpt.Load(m_Paths);
            crTables = cryRpt.Database.Tables;
            FBB_InvoiceManage objInvoiceMng = new FBB_InvoiceManage(true);
            DataGridView xdvgInvoice = objInvoiceMng.xdgvInvoiceManage;
            for (int ix = 0; ix <= xdvgInvoice.Rows.Count - 1; ix++)
            {
                DataRow dr = m_dt.NewRow();
                dr["INVOICEMASTERID"] = "";
                dr["CUSTOMER_NAME"] = "";
                dr["INVOICE_NUMBER"] = "";
                dr["ISSUES_DATE"] = "";
                dr["TOTAL_AMOUNT"] = "";
                dr["AMOUNT_OWING"] = "";

            }

            ///
            CDBConnectionInfo crDBConnection = CUtil.GetConnection();

            TableLogOnInfo LogInfo = new TableLogOnInfo();
            crConnectionInfo.ServerName = crDBConnection.ServerName;
            crConnectionInfo.DatabaseName = "FB_Billing";
            crConnectionInfo.UserID = crDBConnection.UserName;
            crConnectionInfo.Password = crDBConnection.Password;
            crConnectionInfo.IntegratedSecurity = crDBConnection.IntegratedAuth;
            //crTables = cryRpt.Database.Tables;

            foreach (Table crTable_loopVariable in crTables)
            {
                crTable = crTable_loopVariable;
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }


            cryRpt.SetDataSource(m_dt);
            xcrvReports.ReportSource = cryRpt;
            this.Text = "Invoice Report";
        }
        private void PrepareQuatation()
        {
            cryRpt.Load(m_Paths);
            crTables = cryRpt.Database.Tables;

            FBB_QuatationManage objQuotationMng = new FBB_QuatationManage(true);
            DataGridView xdgvQuotation = objQuotationMng.xdgvQuatationManage;

            for (int ix = 0; ix <= xdgvQuotation.Rows.Count - 1; ix++)
            {
                DataRow dr = m_dt.NewRow();
                dr["QUOTATION_NUMBER"] = "";
                dr["CUSTOMER_NAME"] = "";
                dr["QUOTATION_DATE"] = "";
                dr["TOTAL_AMOUNT"] = "";
            }

            CDBConnectionInfo crDBConnectionInfo = CUtil.GetConnection();
            TableLogOnInfo LogOnInfo = new TableLogOnInfo();
            crConnectionInfo.ServerName = crDBConnectionInfo.ServerName;
            crConnectionInfo.DatabaseName = "FB_Billing";
            crConnectionInfo.UserID = crDBConnectionInfo.UserName;
            crConnectionInfo.Password = crDBConnectionInfo.Password;
            crConnectionInfo.IntegratedSecurity = crDBConnectionInfo.IntegratedAuth;
            foreach (Table crTable_loopVariable in crTables)
            {
                crTable = crTable_loopVariable;
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }
            cryRpt.SetDataSource(m_dt);
            xcrvReports.ReportSource = cryRpt;
            this.Text = "Quotation Report";

        }
    }

}


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 28-Jan-13 21:07pm
v2

Take out the two lines:
C#
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

Then compile your program - you will get errors.
GO to the first error - probably on the line:
C#
ReportDocument cryRpt = new ReportDocument();
and put the cursor in the first word that is underlined in red. A small blue box will appear at the beginning of the word. Hover the mouse over the box, and a dropdown will appear. Open the drop down, and it will have possible solutions to the problem. The first one should be "using ..." select it and it will add the using statement for you. Repeat this until your references are correct.
 
Share this answer
 
In visual studio go to project icon on top->properties->change target frame work to .net framework 4. after that in solution explorer-> add reference ,you can see all the crystal report dll and add it.
 
Share this answer
 
v2

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