日期:2014-05-17 浏览次数:20393 次
public partial class login : System.Web.UI.Page { public static string strCon = "server= .; uid=sa; pwd=sa; database=hager"; protected void Page_Load(object sender, EventArgs e) { } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string sqlsel = "select count(*) from tUser where fCode='" + TextBox1.Text + " and fPassword='" + TextBox2.Text + "''"; SqlConnection con = new SqlConnection(strCon); con.Open(); SqlCommand com = new SqlCommand(sqlsel, con); if (Convert.ToInt32(com.ExecuteScalar())> 0) { RegisterStartupScript("", "<script>alert('登录成功!')</script>"); } else { RegisterStartupScript("", "<script>alert('登录失败!')</script>"); } } }
" and fPassword='" + TextBox2.Text + "''";