关于datatable 动态插入行数据的困惑
zdsa 2003-07-24 08:23:39 ..............
Dataable man=new DataTable();
public void GetChildPlaceMan(int[] place)
{
int i,j;
for(i=0;i<place.Length;i++)
{
DataTable men=GetManByPlace(place[i]);
if(men.Rows.Count!=0)
{
for(j=0;j<men.Rows.Count;j++)
{
DataRow dr=man.NewRow();
dr[0]=Convert.ToInt32(men.Rows[j][0].ToString());
dr[1]=men.Rows[j][0].ToString();
man.Rows.Add(dr);
}
}
int[] topplace;
topplace=GetTopPlace(place[i]);
if(topplace!=null)
GetChildPlaceMan(topplace);
}
}
public DataTable GetMenByMan(int manid)
{
man.Columns.Add("menid");
man.Columns.Add("manname");
DataSet ds=new DataSet();
string sqlGetplace="select HR_DutyID from Hr_Duty where UserID='"+manid+"'";
ds=db.GetDataSet(sqlGetplace,"placeparent");
int[] p={Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString())};
GetChildPlaceMan(p);
return man;
}
为什么我在调用上面的方法 public DataTable GetMenByMan(int manid)时,老是报错:名为“menid”的列已属于此 DataTable。