关于命名空间。错误提示(“Test.Database”是“命名空间”,但此处被当做“类型”来使用)
自己写在两个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”