zoukankan      html  css  js  c++  java
  • asp.net 修改

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    
    public partial class update : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string UserID = Request["id"];//id是当前行的用户名
                if (string.IsNullOrEmpty(UserID))
                {
                    Response.Write("<script>window.location.href='query.aspx'</script>");
                }
                else
                {
                    string sql = "select * from Users where UserID = "+UserID;
                    DataTable dt = SQLHelper.ExecuteDataTable(sql);
                    txtUserID.Text = dt.Rows[0]["UserID"].ToString();
                    txtUserName.Text = dt.Rows[0]["UserName"].ToString();
                    txtPwd.Text = dt.Rows[0]["pwd"].ToString();
                    txtphone.Text = dt.Rows[0]["phone"].ToString();
                    txtcardID.Text = dt.Rows[0]["cardID"].ToString();
                }            
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userID = txtUserID.Text;
            string username = txtUserName.Text;
            string pwd = txtPwd.Text;
            string phone = txtphone.Text;
            string cardID = txtcardID.Text;     
    
            string s = "update Users set UserName=@UserName,pwd=@pwd,phone=@phone,cardID=@cardID where UserID=@UserID";
            SqlParameter[] p = { new SqlParameter("@UserName",username),
                                     new SqlParameter("@pwd",pwd),
                                     new SqlParameter("@phone",phone),
                                     new SqlParameter("@cardID",cardID),
                                     new SqlParameter("@UserID",userID),};
            int i = SQLHelper.NonExQuery(s, p);
            if (i == 1)
            {
                Response.Write("<script>alert('修改成功!');window.location='query.aspx';</script>");
            }
        }
    }
  • 相关阅读:
    poj 1050
    poj 2479 Maximum sum
    Trie树结构(AC自动机前奏)(转)
    poj 3624(zeroonepack)
    poj 3630(Phone List )
    KMP算法(AC自动机前奏)(转)
    AC自动机(转)
    AC自动机模板(hdu2222)
    Running CMD.EXE as Local System
    什么是WPF(Avalon)
  • 原文地址:https://www.cnblogs.com/zhang1997/p/8617348.html
Copyright © 2011-2022 走看看