看错误应该是insert的时候主键重复,你的表中是不是用了触发器?

解决方案 »

  1.   

    那就是你触发器的问题了,看看你的触发器的代码是不是在'dbo.nb_JiaBanLog' 这个表的插入上写错了!其实你可以考虑在程序里面写入这个表而不弄个触发器!
      

  2.   

    cmd.ExecuteNonQuery();
    con.close();--------------这里加上这句
    SqlDataAdapter ada=new SqlDataAdapter("select * from nb_JiaBanLog where FormNumber= "+this.jb_FormNumber.Text,Con);//"select * from nb_JiaBanLog where FormNumber= "+this.jb_FormNumber.Text,Con
        DataSet ds=new DataSet();
    ada.Fill(ds);
    DataGrid1.DataSource=ds;
        this.DataGrid1.DataBind();
    Con.Close();
      

  3.   

    表的主外键,
    你这样删不了的,要去掉主外键,或者你sql语句有问题,删的地方不对