Dong Lam Trien

Dong Lam Trien

  • 736
  • 986
  • 149.4k

namespace error when using namespaces that don't match names

Mar 14 2019 1:21 AM
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
//file: ChitietSP.aspx
  1. using System;   
  2. using System.Data;   
  3. using System.Configuration;   
  4. using System.Collections;   
  5. using System.Web;   
  6. using System.Web.Security;   
  7. using System.Web.UI;   
  8. using System.Web.UI.WebControls;   
  9. using System.Web.UI.WebControls.WebParts;   
  10. using System.Web.UI.HtmlControls;   
  11. using System.Diagnostics;   
  12. // Debug using connectSQL;   
  13. // warning   
  14. public partial class _Default : System.Web.UI.Page   
  15. {   
  16.     protected void Page_Load(object sender, EventArgs e)   
  17.     {   
  18.         if (!IsPostBack) { LoadData(); }   
  19.     }   
  20.     string sSQL;   
  21.     private void LoadData()   
  22.     {   
  23.         sSQL = "SELECT * FROM TABKHACHHANG "; sSQL += "ORDER BY MASOPHIEU;";   
  24.         GridView1.DataSource = ClsConnecSQL.FillDatatable(sSQL);   
  25.         //warning   
  26.     }   
  27. }   
//file: clsConnecSQL.cs
  1. using System.Configuration;   
  2. using System.Collections;   
  3. using System.Web;   
  4. using System.Web.Security;   
  5. using System.Web.UI;   
  6. using System.Web.UI.WebControls;   
  7. using System.Web.UI.WebControls.WebParts;   
  8. using System.Web.UI.HtmlControls;   
  9. //using connectSQL;   
  10. namespace connectSQL   
  11. {   
  12.     public class ClsConnecSQL   
  13.     { public static DataTable FillDatatable(string sSQL)   
  14.         { //Do somthing...   
  15.         }   
  16.     }   
  17. }  
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

Answers (4)