
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { gv_UserInfo.DataSource = SqlDbHelper.GetDataTable("select * from tb_UserInfo", null); gv_UserInfo.DataBind(); } } protected void btnInsert_Click(object sender, EventArgs e) { string strUserName = txtUserName.Text; string strUserPwd = txtUserPwd.Text; string strSql = "insert into tb_UserInfo (UserName, UserPwd) values (@pUserName, @pUserPwd)"; SqlParameter[] spa = new SqlParameter[2]; spa[0] = new SqlParameter("@pUserName", SqlDbType.VarChar, 50); spa[0].Value = strUserName; spa[1] = new SqlParameter("@pUserPwd", SqlDbType.VarChar, 50); spa[1].Value = strUserPwd; SqlDbHelper.GetNoneQuery(strSql, spa); gv_UserInfo.DataSource = SqlDbHelper.GetDataTable("select * from tb_UserInfo", null); gv_UserInfo.DataBind(); } protected void btnselect_Click(object sender, EventArgs e) { string strUserName = txtUserName.Text; string strUserPwd = txtUserPwd.Text; string strSql = "select count(*) from tb_Info where UserName = @UserName and UserPwd = @UserPwd "; SqlParameter[] spa = new SqlParameter[2]; spa[0] = new SqlParameter("@pUserName", SqlDbType.VarChar, 50); spa[0].Value = strUserName; spa[1] = new SqlParameter("@pUserPwd", SqlDbType.VarChar, 50); spa[1].Value = strUserPwd; if (int.Parse(SqlDbHelper.GetScalar(strSql, spa).ToString()) > 0) { Response.Write(""); } else { Response.Write(""); } }}
