我有一个开单的工作.里面的dataGridView里面的数据是通过文本框输入然后放到bindingSource集合里面..然后再在dataGridView里面显示出来
  如果我输入错了希望能够删除掉输入错误的那条产品的数据.还有一种情况是如果我输入的产品跟bindingSource已经在集合里面存在的话只把bindingSource里面那个产品的数量进行相加..
  

解决方案 »

  1.   

    是那种显示,你是把文本框输入的放到了dataset里显示还是存到数据库显示呢不管怎么显示 只要改dataset就好了
      

  2.   

    我是用文本框输入的..然后在显示出来..
     只有输入完全后才会存到数据库..现在的问题是如果我要录数据出错了.我需要删除那条数据怎么删除bindingSource集合里面的那条记录
      

  3.   

    你的bindingSource应该是一张datatable吧,你可以先转换成table,然后对table做操作就可以了
      

  4.   

    写一个类,里面写对表操作的方法
    其中删除的如下
    public int DeleteProduct(int iPid, out string strErr)
            {
                int iReturn = 0;
                strErr = string.Empty;
                string strCommand = "delete from product where pid=" + iPid.ToString();            SqlCommand sqlCom = new SqlCommand();
                sqlCom.Connection = sqlCon;
                sqlCom.CommandText = strCommand;
                try
                {
                    sqlCon.Open();
                    sqlCom.ExecuteNonQuery();
                    iReturn = 1;
                }
                catch (Exception exErr)
                {
                    strErr = exErr.ToString();
                    iReturn = 0;
                }
                finally
                {
                    sqlCon.Close();
                    sqlCom.Dispose();
                }
                return iReturn;
            }