您的位置:程序门 -> .net技术 -> c#



关于命名空间。错误提示(“test.database”是“命名空间”,但此处被当做“类型”来使用)


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于命名空间。错误提示(“test.database”是“命名空间”,但此处被当做“类型”来使用)[已结贴,结贴人:jiejifeng]
发表于:2007-08-24 10:33:06 楼主
自己写在两个class,放在   app_code下,一个为database.cs,用来数据库操作,一个为customer.cs,作为business对象类.

database.cs的大致代码为:
using   system;
using   system.componentmodel;
using   system.collections;
using   system.diagnostics;
using   system.data;
using   system.data.sqlclient;
using   system.configuration;

namespace   test.database
{
    ///   <summary>
    ///   ado.net   data   access   using   the   sql   server   managed   provider.
    ///   </summary>
    public   class   database   :   idisposable  
    {
        //   connection   to   data   source
        private   sqlconnection   conn;


        public   database()
        {
            //
            //   todo:   在此处添加构造函数逻辑
            //
            try
            {
                //open();
               
            }
            catch  
            {
                //
                //string   aa   =   e.message;
                //string   aa   =   e.message.tostring();

            }
            finally
            {
                //conn.close();
                //conn.dispose();
            }
        }
    }
}


///////////   customer.cs类   ////////////////////
using   system;
using   system.data;
using   system.configuration;
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   test.database;

namespace   test.customer
{
    ///   <summary>
    ///   customer   的摘要说明
    ///   普通用户的的类
    ///   </summary>
    public   class   customer
    {
     
    }
private   void   getcustomerinfo(int   id)
        {
            database   dbase   =   new   database();   //     *****这行报错****   //
            string   sql;
        }

    }
}

报错说
错误提示(“test.database”是“命名空间”,但此处被当做“类型”来使用)
发表于:2007-08-24 10:37:351楼 得分:7
test.database.database   dbase   =   new   test.database.database();
发表于:2007-08-24 10:37:412楼 得分:5
namespace   test.database   另外取个名字咯
发表于:2007-08-24 10:40:033楼 得分:8
对于database这个名字编译器会先找到test.database而不是test.database.database
所以提示为命名空间
发表于:2007-08-24 10:47:414楼 得分:0
谢谢两位。     难道像在上面写命名的时候只应该写   test   而不是写成   test.database   ?
发表于:2007-08-24 10:48:185楼 得分:0
难道像在上面写命名的时候只应该写  
namespace   test
  而不是写成   namespace   test.database   ?


快速检索

最新资讯
热门点击