日期:2014-05-17  浏览次数:20859 次

关于C#廉洁ACCESS数据库后 使用UPDATE更新数据库报错的问题!
代码如下
 private void button1_Click(object sender, EventArgs e)
        {
            string number = textBox1.Text;
            string password = textBox2.Text;
            OleDbConnection conn = new OleDbConnection();
            conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source =图书馆.mdb";
            conn.Open();
            string sql = "select * from atable where anumber= '" + number + "'";
            OleDbCommand cmd = new OleDbCommand(sql,conn);
            OleDbDataAdapter oleda = new OleDbDataAdapter(sql,conn);
            OleDbCommandBuilder olecb = new OleDbCommandBuilder(oleda);
            DataTable oledt = new DataTable();
            oleda.Fill(oledt);
            object result = cmd.ExecuteScalar();
            if (result != null)
            {
                if (oledt.Rows[0]["password"].ToString() == textBox2.Text.ToString())
                {
                    if (textBox3.Text == textBox4.Text)
                    {
                        if (MessageBox.Show("确定修改密码吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            oledt.Rows[0]["password"] = textBox3.Text;
                            oleda.Update(oledt);
                            MessageBox.Show("修改成功!");
                            this.Close();
         &nbs