[color=#0000FF]CS0246: 找不到类型或命名空间名称“DataAcess”(是否缺少 using 指令或程序集引)[/color]请教下大家这个问题怎么解决?相关代码:using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using Accessibility;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string strcmd = "";
int i;
DataAcess mydataAcess = new DataAcess( );
if (TextBox1.Text.Trim() != "" && TextBox2.Text.Trim() != "")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "select count(*) from admin where 用户名='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 1;
}
if (DropDownList1.Text == "教师")
{
strcmd = "select count(*) from teacher where 教师编号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 2;
}
if (DropDownList1.Text == "学生")
{
strcmd = "select count(*) from student where 学号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 3;
}
i = mydataAcess.ExecuteScalar(strcmd);
if (i == 1)
{
Session["Username"] = TextBox1.Text.ToString();
if (temp == 1)
Response.Redirect("Default.aspx");
if (temp == 2)
Response.Redirect("Default2.aspx");
if (temp == 3)
Response.Redirect("Default3.aspx");
}
else
Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误!');history.go(-1);</script>");
}
else
{
Response.Write("<script LANGUAGE='javascript'>alert('请输入账号或密码!');history.go(-1);</script>");
TextBox1.Text = "";
TextBox2.Text = "";
}
}
}
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using Accessibility;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string strcmd = "";
int i;
DataAcess mydataAcess = new DataAcess( );
if (TextBox1.Text.Trim() != "" && TextBox2.Text.Trim() != "")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "select count(*) from admin where 用户名='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 1;
}
if (DropDownList1.Text == "教师")
{
strcmd = "select count(*) from teacher where 教师编号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 2;
}
if (DropDownList1.Text == "学生")
{
strcmd = "select count(*) from student where 学号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 3;
}
i = mydataAcess.ExecuteScalar(strcmd);
if (i == 1)
{
Session["Username"] = TextBox1.Text.ToString();
if (temp == 1)
Response.Redirect("Default.aspx");
if (temp == 2)
Response.Redirect("Default2.aspx");
if (temp == 3)
Response.Redirect("Default3.aspx");
}
else
Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误!');history.go(-1);</script>");
}
else
{
Response.Write("<script LANGUAGE='javascript'>alert('请输入账号或密码!');history.go(-1);</script>");
TextBox1.Text = "";
TextBox2.Text = "";
}
}
}
using 命名空间;
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using Accessibility;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string strcmd = "";
int i;
DataAcess mydataAcess = new DataAcess( );
if (TextBox1.Text.Trim() != "" && TextBox2.Text.Trim() != "")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "select count(*) from admin where 用户名='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 1;
}
if (DropDownList1.Text == "教师")
{
strcmd = "select count(*) from teacher where 教师编号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 2;
}
if (DropDownList1.Text == "学生")
{
strcmd = "select count(*) from student where 学号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 3;
}
i = mydataAcess.ExecuteScalar(strcmd);
if (i == 1)
{
Session["Username"] = TextBox1.Text.ToString();
if (temp == 1)
Response.Redirect("Default.aspx");
if (temp == 2)
Response.Redirect("Default2.aspx");
if (temp == 3)
Response.Redirect("Default3.aspx");
}
else
Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误!');history.go(-1);</script>");
}
else
{
Response.Write("<script LANGUAGE='javascript'>alert('请输入账号或密码!');history.go(-1);</script>");
TextBox1.Text = "";
TextBox2.Text = "";
}
}
}
1. 你要通过Add reference...把DataAcess 所在的assembly(dll)加入到你的工程中。
2. 要在文件前面引用DataAcess 所在的命名空间。
在Add reference后,可以双击加入的assembly,会进入Ojbect Browser.
在这里可以看到DataAcess 所在的命名空间。