命名空间“System.Data”中不存在类型或命名空间名称“sqlclient”(是缺少程序集引用吗?)
各位高手请帮忙看下以下代码哪里有问题?请多多指教。我用是MicrosoftVisualStudio2008usingSystem;usingSystem.Collecti...
各位高手请帮忙看下以下代码哪里有问题?请多多指教。我用是Microsoft Visual Studio 2008
using System;
using System.Collections;
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;
namespace test2_1
{
/// <summary>
/// login 的摘要说明。
/// </summary>
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string username = Request.form["username"].tostring();
string password = Request.Form.Get("password").tostring();
sqlconnection con = new sqlconnection("server=.;database=login;uid=sa;pwd=;");
con.open();
sqlcommand cmd = new sqlcommand("select oount(*) from login where username='" + username + "'and password='" + password + "',con)");
int count = Convert.ToInt32(cmd.Executescalar());
if (count > 0)
{
Response.Redirect("main.aspx");
}
else
{
Response.Redirect("loginFail.html");
}
//在此处放置用户代码以初始化页面
}
}
}
gudieaofei 先生,非常感谢您及时的回复
但是
“在项目上点右键->添加引用->.net选项卡->选择system.Data.sqlClient,点击确定 ”
照此操作中我找不到“system.Data.sqlClient”此选项,我该怎么做呢,谢谢! 展开
using System;
using System.Collections;
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;
namespace test2_1
{
/// <summary>
/// login 的摘要说明。
/// </summary>
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string username = Request.form["username"].tostring();
string password = Request.Form.Get("password").tostring();
sqlconnection con = new sqlconnection("server=.;database=login;uid=sa;pwd=;");
con.open();
sqlcommand cmd = new sqlcommand("select oount(*) from login where username='" + username + "'and password='" + password + "',con)");
int count = Convert.ToInt32(cmd.Executescalar());
if (count > 0)
{
Response.Redirect("main.aspx");
}
else
{
Response.Redirect("loginFail.html");
}
//在此处放置用户代码以初始化页面
}
}
}
gudieaofei 先生,非常感谢您及时的回复
但是
“在项目上点右键->添加引用->.net选项卡->选择system.Data.sqlClient,点击确定 ”
照此操作中我找不到“system.Data.sqlClient”此选项,我该怎么做呢,谢谢! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询