62,041
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace EX_1
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=R504-14;Initial Catalog=Temp;Integrated Security=True");
conn.Open();
SqlCommand cmd = new SqlCommand("select Password from UserInfo where UserName=" + "'" + TextBox1.Text + "'",conn);
SqlDataReader dr = cmd.ExecuteReader();
string password = dr["Password"].ToString();
if(dr.Read())
{
if (password.Equals(TextBox2.Text))
{
Response.Write("yes");
}
else
{
Response.Write("no");
}
}
conn.Close();
}
}
}