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.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection sqlcon;
SqlDataAdapter sqlDataAdapter;
DataSet dataset;
protected void Page_Load(object sender, EventArgs e)
{
//try
//{
sqlcon = new SqlConnection("server=.;Initial Catalog=UserInfo;Integrated Security=True");
//}
//catch (Exception ee)
//{
//lblMessage.Text = ee.Message.ToString();
//}
}
protected void btnEnter_Click(object sender, EventArgs e)
{
try
{
sqlcon.Open();
sqlDataAdapter = new SqlDataAdapter("select * from [User] where UserName='" + this.dropUserName.Text.ToString() + "'", sqlcon);
dataset = new DataSet();
sqlDataAdapter.Fill(dataset, "User");
if (dataset.Tables["User"].Rows[0][1].ToString() == this.txtPassWord.Text.ToString())
{
lblMessage.Text = "登录成功!!!";
}
else
{
lblMessage.Text = "密码不正确!!!";
}
}
catch (Exception ee)
{
lblMessage.Text = ee.Message.ToString();
}
}
}
SQL数据库
database:userInfo
表名:User
共两个字段:UserName varchar not null
Password varchar not null
有什么 不会的给我留一定 回答》