寻找一个登陆代码,c#
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 System.Data.Sql;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnlogin_Click(object sender, EventArgs e)
{
SqlConnection con = DB.createCon();
SqlCommand cmd = new SqlCommand();
= "select count(*) from login where name='" + this.txtusername.Text + "'and password='" + this.txtpassword.Text+"'";
cmd.Connection = con;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
if ( txtusername== && txtpassword=)错误就在这里使用 rows.[哪行][哪列] 还是使用string id pass;id= String id, pass;
id. ==Convert.ToString(0);
pass = dr.GetString(1);
if (id == this.txtusername.Text && pass == this.txtpassword.Text)结果都达不到,请人帮帮忙看看怎么做!!!!!!!!!
{
Response.Write("<script>alert('登陆成功');location.href='index.aspx';</script>");
}
else { Response.Write("<script>alert('登陆失败,请核对你的用户名和密码 .');location.href='login.aspx';</script>"); }
}
else
{
Response.Write("<script>alert('登陆失败,请核对你的用户名和密码 .');location.href='login.aspx';</script>");
}
}
}