for(int j=0;j<HDS.Tables["T_hppcustomertype"].Rows.Count;j++)
{
String RowT=HDS.Tables["T_hppcustomertype"].Rows[j]["customerid"].ToString();
DataRow[] RowM = HDS.Tables["T_hppcustomertype"].Select(RowT+"="+Cuid);
foreach (DataRow dr in RowM)
{
dr.Delete();
dr.EndEdit();
}
HDS.AcceptChanges(); 
}
请问为什么上面这段代码不能完成删除RowT=Cuid条件的字段??
有什么解决方法吗?

解决方案 »

  1.   

    for(int j=0;j<HDS.Tables["T_hppcustomertype"].Rows.Count;j++)
    {
    //String RowT=HDS.Tables["T_hppcustomertype"].Rows[j]["customerid"].ToString();
    DataRow[] RowM = HDS.Tables["T_hppcustomertype"].Select("customerid="+Cuid);
    foreach (DataRow dr in RowM)
    {
             dr.Delete();
    dr.EndEdit();
    }
    HDS.AcceptChanges();//如果你想更新数据库,请更新完后再AcceptChanges. 
    }
      

  2.   

    上面的错了,下面这些代码就够了.
    DataRow[] RowM = HDS.Tables["T_hppcustomertype"].Select("customerid="+Cuid);
    foreach (DataRow dr in RowM)
    {
    dr.Delete();
    dr.EndEdit();
    }
      

  3.   

    RowT+"="+Cuid   表达式形势错了