標籤:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class index : System.Web.UI.Page
{
private static string connString = "Data Source=192.168.1.112;Initial Catalog=MaxsysHelpCenter;User ID=maxsys;Password=a123456789~";
protected void BtnLogin_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
if (conn.State != ConnectionState.Open)
conn.Open();
var cmd = new SqlCommand("select * from T_index_land where S_UserName=‘this.txtUserName.value‘ and S_PassWord=‘this.txtPassWrod.val‘", conn);
using (var reader = cmd.ExecuteReader())
{
//判斷結果。
if (reader.HasRows)
{
Response.Write("<script>alert(‘登入成功!‘);location=‘javascript:history.go(-1)‘</script>");//成功提示
}
else
{
Response.Write("<script>alert(‘登入失敗!‘);location=‘javascript:history.go(-1)‘</script>");//成功提示
}
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
C# 初學者,寫了這個點擊事件,可是帳號密碼輸入正確以後點擊以後什麼事都沒有發生啊,線上求解答,急啊!!!!謝謝啊!!!