CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2007
    Posts
    405

    namespace error when using namespaces that don't match namespace ?

    Suppose I create an asp.net website project that loads data into griview from the class library, declaring the library to use loading data for griview

    Code:
    //file: ChitietSP.aspx
    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;                            // warning
    
    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 * FROM TABKHACHHANG ";
            sSQL += "ORDER BY MASOPHIEU;";       
            
            GridView1.DataSource = ClsConnecSQL.FillDatatable(sSQL); //warning
        }
        
    }
    Code:
    //file: clsConnecSQL.cs
    
    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 connectSQL;
    
    namespace connectSQL 
    {
        public class ClsConnecSQL
        {
            public static DataTable FillDatatable(string sSQL)
            {
               //Do somthing...
            }
        }
        
    }
    I have declared the library namespace to be used is still error, asking you to help me
    using connectSQL; // warning
    GridView1.DataSource = ClsConnecSQL.FillDatatable (sSQL); // error not found connectSQL namespace
    Last edited by 2kaud; March 16th, 2019 at 06:08 AM. Reason: Added code tags

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: namespace error when using namespaces that don't match namespace ?

    Is clsConnecSQL.cs included as a file in your project? In other words, is it getting built?

  3. #3
    Join Date
    Sep 2007
    Posts
    405

    Re: namespace error when using namespaces that don't match namespace ?

    I send the error example to you, you can see and fix the error for me, you can see the attached file

    http://www.mediafire.com/file/iiak7w...p_net.rar/file

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: namespace error when using namespaces that don't match namespace ?

    Quote Originally Posted by dongtrien View Post
    I send the error example to you, you can see and fix the error for me, you can see the attached file

    http://www.mediafire.com/file/iiak7w...p_net.rar/file
    Please attach the file directly if you would like us to look at it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured