在做网站,老提示当前上下文中不存在名称“DB”。求指教
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingS...
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Sql;
public partial class en_uk_cms_eco_login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txt_username.Focus();
Session["login"] = null;
}
}
protected void btn_login_Click(object sender, ImageClickEventArgs e)
{
HttpCookie cookie = new HttpCookie("lxy");
try
{
string userid, userpwd;
userid = DB.HtmlEncode(this.txt_username.Value.Trim());
userpwd = this.txt_password.Value.Trim();
if (String.Compare(Session["CheckCode"].ToString(), txt_Vcode.Value, true) != 0)
{
Response.Write("<script>alert('验证码错误!');history.go(-1)</script>");
Response.End();
}
int count = DB.SelectCount("select count(*) from [user] where [userid]='" + userid + "' and [userpwd]='" + userpwd + "'");
string userpower = "" ;
string id = "";
DataSet ds = DB.SelectData("Select id,userpower from [user] where [userid] = '" + userid + "' and [userpwd] = '" + userpwd + "'","login");
DataTable dt = ds.Tables[0];
userpower = dt.Rows[0]["userpower"].ToString();
id = dt.Rows[0]["id"].ToString();
if (count == 1)
{
cookie.Values.Add("id", id);
cookie.Values.Add("userid",userid);
cookie.Values.Add("userpower",userpower);
Response.AppendCookie(cookie);
Session["login"] = "1";
Response.Redirect("newslist.aspx");
Response.End();
}
else
{
Response.Write("<script>alert('登陆失败,请核对信息!');history.go(-1)</script>");
Response.End();
}
}
catch
{
Response.Write("<script>alert('登陆失败,请核对信息.');history.go(-1)</script>");
Response.End();
}
//catch (Exception ex)
//{
// throw new Exception(ex.Message);
//}
}
} 展开
using System.Data;
using System.Configuration;
using System.Collections;
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 System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Sql;
public partial class en_uk_cms_eco_login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txt_username.Focus();
Session["login"] = null;
}
}
protected void btn_login_Click(object sender, ImageClickEventArgs e)
{
HttpCookie cookie = new HttpCookie("lxy");
try
{
string userid, userpwd;
userid = DB.HtmlEncode(this.txt_username.Value.Trim());
userpwd = this.txt_password.Value.Trim();
if (String.Compare(Session["CheckCode"].ToString(), txt_Vcode.Value, true) != 0)
{
Response.Write("<script>alert('验证码错误!');history.go(-1)</script>");
Response.End();
}
int count = DB.SelectCount("select count(*) from [user] where [userid]='" + userid + "' and [userpwd]='" + userpwd + "'");
string userpower = "" ;
string id = "";
DataSet ds = DB.SelectData("Select id,userpower from [user] where [userid] = '" + userid + "' and [userpwd] = '" + userpwd + "'","login");
DataTable dt = ds.Tables[0];
userpower = dt.Rows[0]["userpower"].ToString();
id = dt.Rows[0]["id"].ToString();
if (count == 1)
{
cookie.Values.Add("id", id);
cookie.Values.Add("userid",userid);
cookie.Values.Add("userpower",userpower);
Response.AppendCookie(cookie);
Session["login"] = "1";
Response.Redirect("newslist.aspx");
Response.End();
}
else
{
Response.Write("<script>alert('登陆失败,请核对信息!');history.go(-1)</script>");
Response.End();
}
}
catch
{
Response.Write("<script>alert('登陆失败,请核对信息.');history.go(-1)</script>");
Response.End();
}
//catch (Exception ex)
//{
// throw new Exception(ex.Message);
//}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询