using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;

public partial class memrep : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnrep_Click(object sender, EventArgs e)
    {
      string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|mydata.mdb";
      OleDbConnection conn = new OleDbConnection(strcon);
      conn.Open();
      string mname = txtname.Text;
      string oldpwd = txtold.Text;
      string newpwd = txtnew.Text;
      string sql1 = "select count(*) from members where mname='" + mname + "' and mpwd='" + oldpwd + "'";
      string sql2 = "update members set mpwd='" + newpwd + "' where mname='" + mname + "'";
      OleDbCommand ocmd1 = new OleDbCommand(sql1, conn);
      OleDbCommand ocmd2 = new OleDbCommand(sql2, conn);
      if (Convert.ToInt32(ocmd1.ExecuteScalar()) > 0)
      {
        ocmd2.ExecuteNonQuery();
        lblmes.Text = "修改成功";
      }
      else
      {
        lblmes.Text = "修改失败，请检查用户名和密码是否正确";
      }
      conn.Close();
    }
}
