using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;public partial class Default2 : System.Web.UI.Page
{
    private string AcessConectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.We    protected void Page_Load(object sender, EventArgs e)
    {    }
    protected void Button1_Click(object sender, EventArgs e)
    {
                try
        {
            OleDbConnection Conn = new OleDbConnection(AcessConectionStr);
            Conn.Open();
            string name = this.TextBox1.Text;
            string pwd = this.TextBox2.Text;
            string strSQL = "INSERT INTO login(userName,pwdInput) values('" + name + "','" + pwd + "')";
            OleDbCommand AcessCommand = new OleDbCommand(strSQL, Conn);
            AcessCommand.ExecuteNonQuery();
            Conn.Close();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }    
    }
}

解决方案 »

  1.   

    不好意思copy错了.
    ==============================
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.OleDb;
    public partial class Default2 : System.Web.UI.Page
    {
        private string AcessConectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Test.mdb";    protected void Page_Load(object sender, EventArgs e)
        {    }
        protected void Button1_Click(object sender, EventArgs e)
        {
                    try
            {
                OleDbConnection Conn = new OleDbConnection(AcessConectionStr);
                Conn.Open();
                string name = this.TextBox1.Text;
                string pwd = this.TextBox2.Text;
                string strSQL = "INSERT INTO login(userName,pwdInput) values('" + name + "','" + pwd + "')";
                OleDbCommand AcessCommand = new OleDbCommand(strSQL, Conn);
                AcessCommand.ExecuteNonQuery();
                Conn.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }    
        }
    }
      

  2.   

    private string AcessConectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ Server.MapPath("../Test.mdb"); "../Test.mdb"为相对路径
      

  3.   

    请问要引入个什么别的命名空间不?
    ======================
        private string AcessConectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+server.mappath("Test.mdb"); 出错提示:上下文中不存在名称server.
      

  4.   

    Server.MapPath   注意大小写