应该是LZ代码问题,只更改了本地的DataSet,实际上没有变更数据库.
应该把代码贴出来,好做进一步分析.

解决方案 »

  1.   

    贴出答案来才是道理
    -----------------
    up~up~
      

  2.   

     private void ExecuteSQL(string SQL)
            {
                String myConStr = "Provider=Microsoft.Jet.OLEDB.4.0;";
                myConStr += "Data Source=FilmManager.mdb;";
                OleDbConnection myCon = new OleDbConnection(myConStr);
                myCon.Open();
                OleDbCommand myCom = new OleDbCommand();
                myCom.CommandType = CommandType.Text;
                myCom.CommandText = SQL;
                myCom.Connection = myCon;
                myCom.ExecuteNonQuery();
            }        }        private void Employees_Load(object sender, EventArgs e)
            {
                // TODO: 这行代码将数据加载到表“filmManagerDataSet.Employee”中。您可以根据需要移动或移除它。
                this.employeeTableAdapter.Fill(this.filmManagerDataSet.Employee);
                this.employeeTableAdapter.Fill(this.filmManagerDataSet.Employee);
                this.employeeTableAdapter.Fill(this.filmManagerDataSet.Employee);
                this.textBox1.Text=(Navigator.Position + 1).ToString();
                this.label12.Text = Navigator.Count.ToString();
            }        private void button5_Click(object sender, EventArgs e)
            {
                string insStr = "INSERT INTO Employee(EmployeeID,Name,Age,Sex,ID,Title,Salary,Phone,Address";            insStr += ",HireDate) values('" + textBox1.Text + "','" + textBox2.Text+"',"+textBox3.Text;            insStr += ",'" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text;            insStr += "'," + textBox7.Text + ",'" + textBox8.Text + "','" + textBox9.Text;            insStr += "'," + textBox10.Text + ")";            ExecuteSQL(insStr);
            }        private void button6_Click(object sender, EventArgs e)
            {
                if (this.textBox1.Text == "")
                {
                    MessageBox.Show("必须输入EmployeeID,才能惊醒删除");
                    return;
                }
                else
                {
                    if (MessageBox.Show("确实要删除吗?", "确认", MessageBoxButtons.OKCancel)
                        == DialogResult.Cancel)
                        return;
                    string delStr = "DELETE FROM Employee WHERE EmployeeID='";
                    delStr += this.textBox1.Text+"'";
                    ExecuteSQL(delStr);
                }
            }        private void button7_Click(object sender, EventArgs e)
            {
                if (this.textBox1.Text == "")
                {
                    MessageBox.Show("必须输入EmployeeID,才可以进行更新!");
                    return;
                }
                else
                {
                    if (MessageBox.Show("确实要更新吗?", "确认", MessageBoxButtons.OKCancel)
                        == DialogResult.Cancel)
                        return;
                    string upStr = "UPDATE Employee SET Name='" + textBox2.Text;
                    upStr += "',Age=" + textBox3.Text + ",Sex='" + textBox4.Text;
                    upStr += "',ID='" + textBox5.Text + "',Title='" + textBox6.Text;
                    upStr += "',Salary=" + textBox7.Text + ",Phone='" + textBox8.Text;
                    upStr += "',Address='" + textBox9.Text + "',HireDate='" + textBox10.Text;
                    upStr += "'  WHERE EmployeeID='" + textBox1.Text+"'";
                    ExecuteSQL(upStr);
                }
            }
    我还用到了数据集,正如二楼的哥们儿说的,只是修改了当地的数据集,我回到project里面看的时候一共有两个数据库,一个在debug里面,一个就在我建立的工程里面。
      

  3.   

    把这个改成了这个还是有问题
     private void ExecuteSQL(string SQL)
            {
                string myConStr = "Persist Security Info=false;Initial Catalog=FilmManager;";
                myConStr += "Data Source=localhost;Integrated Security=SSPI;";
                myCon.ConnectionString = myConStr;
                try
                {
                    myCon.Open();
                    myCom.CommandText = SQL;
                    myCom.CommandType = CommandType.Text;
                    myCom.Connection = myCon;
                    myCom.ExecuteNonQuery();
                    myCom.CommandText = "select * from Employee";
                    myDS.Clear();
                    myAD.SelectCommand = myCom;
                    myAD.Fill(myDS, "Empolyee");
                    this.label12.Text = Navigator.Count.ToString();
                }
      

  4.   

    具体的代码我没有去分析,不过你的EXECUTESQL的函数中的myCon打开前应先判断一下是否已经打开,在用完它后是不是应该关闭呢!
      

  5.   

    1.
    String   myConStr   =   "Provider=Microsoft.Jet.OLEDB.4.0;"; 
    myConStr   +=   "Data   Source=FilmManager.mdb;"; 
    -----------------------------------------------
    使用绝对路径,修改如下
    myConStr   += "Data   Source=" +System.IO.Path.GetDirectoryName( Application.ExecutablePath)+"\\FilmManager.mdb;"; 
    你要注意,调试时的路径是在debug目录下.2.
    string insStr ="INSERT INTO Employee(EmployeeID,Name,Age,Sex,ID,Title,Salary,Phone,Address"; 
    ---------------------------
    如果你不记得Access的保留字,那么养成一个好的习惯,在所有字段名和表名上加[]
    string insStr ="INSERT INTO [Employee]([EmployeeID],[Name],[Age],[Sex],[ID],[Title],[Salary],[Phone],[Address]"; 3.
    LS所述是正确的.4.
    按以上方法修改后,再测试,特别注意操作的数据库的路径,别看成另外的数据库了