private void button1_Click(object sender, EventArgs e)
        {
            //验证提交
            OleDbConnection con = DB.creatOleCon();
            con.Open();
            OleDbCommand cmd1 = DB.creatOleComd("select * from xtbgznr where 文件编号='" + textBox2.Text + "'", con);
            if (!UserInfo.judgeUserid(con, cmd1) || UserInfo.文件编号 == textBox2.Text.Trim())
            {
                MessageBox.Show("此文件不存在!");
            }
            else
            {
                string update = string.Format("update xtbgznr set 工作内容='{0}',文件编号='{1}'where 文件编号='{2}'", richTextBox1.Text, textBox2.Text, UserInfo.文件编号);
                OleDbCommand cmd = DB.creatOleComd(update, con);
                if (DB.Insert(cmd))
                {
                    MessageBox.Show("添加成功!");
                }
                else
                {
                    MessageBox.Show("添加失败!");
                }
            }
        }
查了下应该是xtbgznr . 工作内容未DBNull.value造成的,但是应该怎么解决呀,没看明白度娘的,应该怎么修改呀

解决方案 »

  1.   

    断点监控这个值类型DBNull
      

  2.   

    赋值的时候先判断v!=DBNull.Value或在SQL语句处理掉Null值
      

  3.   

    https://blog.csdn.net/tony0225/article/details/17395489
      

  4.   

    做一个判断 
    if(update  !=DB.NULL)
    {
       OleDbCommand cmd = DB.creatOleComd(update, con);
                    if (DB.Insert(cmd))
                    {
                        MessageBox.Show("添加成功!");
                    }
                    else
                    {
                        MessageBox.Show("添加失败!");
                    }
    }
      

  5.   

    一看就是没测试过
    DBNULL.Value