using System;
using System.Data;
using System.Data.SqlClient;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string userName = this.tbUserName.Text;
string pwd = this.tbPwd.Text;
string sql = "select * from tb_user where id='" + userName + "' and passwd='" + pwd + "'";
String url = ConfigurationManager.ConnectionStrings["csConnectionString"].ConnectionString;
DataSet dataSet = new DataSet("user");
using (SqlConnection connection = new SqlConnection(url))
{
connection.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, connection);
da.Fill(dataSet);
connection.Close();
}
if (dataSet.Tables[0].Rows.Count > 0)
{
Response.Write("<script>alert('login success');</script>");
}
else
{
Response.Write("<script>alert('login failed');</script>");
}
}
}