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 memadd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnadd_Click(object sender, EventArgs e)
    {
      string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|mydata.mdb";
      OleDbConnection conn = new OleDbConnection(strcon);
      string mname = txtname.Text;
      string mpwd = txtpwd.Text;
      string medu = ddledu.SelectedValue;
      Int32 msex = Convert.ToInt32(rdbtnsex.SelectedValue);
      string sql0 = "insert into members(mname,mpwd,msex,medu) values('" + mname + "','" + mpwd + "','" + msex + "','" + medu + "')";
      try
      {
        conn.Open();
        OleDbCommand ocmd = new OleDbCommand(sql0, conn);
        ocmd.ExecuteNonQuery();
        Response.Write("添加成功！");
      }
      catch (Exception error)
      {
        Response.Write("添加失败！");
      }
      finally
      {
        conn.Close();
      }
    }
}
