6 Replies - 804 Views - Last Post: 07 May 2019 - 09:38 PM

#1 dongtrien   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 84
  • Joined: 17-June 15

why's the error not found namespace or class ?

Posted 04 May 2019 - 12:04 AM

You see the example below why the error not found namespace or class ?
http://www.mediafire...sp_net.rar/file

I have an error not finding the derived class:
GridView1.DataSource = clsConnecSQL.FillDatatable(sSQL); //It's not find clsConnecSQL.xxx ???
Is This A Good Question/Topic? 0
  • +

Replies To: why's the error not found namespace or class ?

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,228
  • Joined: 12-December 12

Re: why's the error not found namespace or class ?

Posted 04 May 2019 - 02:35 AM

Post relevant code directly here in the forum, not just as an external resource.
Was This Post Helpful? 0
  • +
  • -

#3 dongtrien   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 84
  • Joined: 17-June 15

Re: why's the error not found namespace or class ?

Posted 07 May 2019 - 12:58 AM

View Postandrewsw, on 04 May 2019 - 02:35 AM, said:

Post relevant code directly here in the forum, not just as an external resource.


file ChitietSP.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Diagnostics;               // Debug
//using connectSQL;
//using ROOT_Namespace.connectSQL;


    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        string sSQL;
        private void LoadData()
        {


            sSQL = "SELECT NGAY, MASOPHIEU, KHACHDUA, TONGTIEN, TONGTHU, TENKH, TEL, ADRESS, GIAM, DOITRA, TTTHANHTOAN, THANHTOAN, MANHANVIEN, NHANVIEN ";
            sSQL += "FROM TABKHACHHANGNOCTTMP ";
            sSQL += "ORDER BY MASOPHIEU;";
            Debug.Print("sSQL: " + sSQL.ToString());
            //DataTable dtKhachNoTmp = clsConnecACS.FillDatatable(sSQL);
            //ClsConnecSQL abc = new ClsConnecSQL();
            //GridView1.DataSource = abc.FillDatatable(sSQL);
            GridView1.DataSource = ClsConnecSQL.FillDatatable(sSQL);
        }

        private void LoadData(string tenNhanVien)
        {
            sSQL = "SELECT NGAY, MASOPHIEU, KHACHDUA, TONGTIEN, TONGTHU, TENKH, TEL, ADRESS, GIAM, DOITRA, TTTHANHTOAN, THANHTOAN, MANHANVIEN, NHANVIEN ";
            sSQL += "FROM TABKHACHHANGNOCTTMP ";
            sSQL += "WHERE TABKHACHHANGNOCTTMP.TEN = N'" + tenNhanVien + "' ";
            sSQL += "ORDER BY MASOPHIEU;";
            Debug.Print("sSQL: " + sSQL.ToString());

            GridView1.DataSource = ClsConnecSQL.FillDatatable(sSQL);
        }

        protected void btnSearch_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSearch.Text))
            {
                lblMessage.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text = "Nhập [Tên nhân viên] cần t́m";
            }
            else
            {
                lblMessage.Text = "";
                LoadData(txtSearch.Text.Trim());
            }
        }
    }





file clsConnecSQL.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Drawing;        
using System.Diagnostics;    
using System.Data.SqlClient; 
//using System.Windows.Forms;  
using System.Configuration;  

//using connectSQL;

namespace connectSQL //System.Web.UI.Page //
{
    public class ClsConnecSQL
    {
        
        public static DataTable FillDatatable(string sSQL)
        {
            string connectionString = "Server=MICROSOFT;uid=sa;pwd=123456;database=NhaDat";
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();
            DataTable dataTable = new DataTable();
            SqlDataAdapter adapter = new SqlDataAdapter(sSQL, sqlConn);
            adapter.Fill(dataTable);

            return dataTable;
        }

        //public static DataTable Plus(int a, int B)/>/>
        //{
        //    return a + b;
        //}



    }   
}

        


Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,228
  • Joined: 12-December 12

Re: why's the error not found namespace or class ?

Posted 07 May 2019 - 01:03 AM

Please quote the exact details of the error(s).

You have commented out //using connectSQL; in the first file but you need this to locate a class in a different namespace.

Is there other information you can tell us about the location and namespaces of these files?
Was This Post Helpful? 0
  • +
  • -

#5 dongtrien   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 84
  • Joined: 17-June 15

Re: why's the error not found namespace or class ?

Posted 07 May 2019 - 01:25 AM

View Postandrewsw, on 07 May 2019 - 01:03 AM, said:

Please quote the exact details of the error(s).

You have commented out //using connectSQL; in the first file but you need this to locate a class in a different namespace.

Is there other information you can tell us about the location and namespaces of these files?


I have an error not finding the derived class:
GridView1.DataSource = clsConnecSQL.FillDatatable(sSQL); //It's not find clsConnecSQL.xxx ???
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6818
  • View blog
  • Posts: 28,228
  • Joined: 12-December 12

Re: why's the error not found namespace or class ?

Posted 07 May 2019 - 01:39 AM

Quote the exact details, which includes line numbers.
Was This Post Helpful? 0
  • +
  • -

#7 dongtrien   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 84
  • Joined: 17-June 15

Re: why's the error not found namespace or class ?

Posted 07 May 2019 - 09:38 PM

View Postandrewsw, on 07 May 2019 - 01:39 AM, said:

Quote the exact details, which includes line numbers.


line 39 and line 50
GridView1.DataSource = clsConnecSQL.FillDatatable(sSQL); //It's not find clsConnecSQL.xxx ???
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1