我有值,我想将其分配给dataset
我尝试如下,但它没有效果。
string strExp = "";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strExp = "RAName = '" + ds.Tables[0].Rows[i]["RAName"].ToString() + "'";
DataRow[] dr= ds.Tables[0].Select(strExp);
}
DataSet dsNew = new System.Data.DataSet();
dsNew = ds.Tables[0].Select(strExp);
请告诉我如何为dataset
答案 0 :(得分:1)
您没有致电AcceptChanges:
string strExp = "";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strExp = "RAName = '" + ds.Tables[0].Rows[i]["RAName"].ToString() + "'";
DataRow[] dr= ds.Tables[0].Select(strExp);
}
ds.Tables[0].AcceptChanges(); //Commits all the changes made to this table since the last time AcceptChanges was called.
DataTable dtNew = ds.Tables[0].Select(strExp).CopyToDataTable();
DataSet dsNew = new System.Data.DataSet();
dsNew.Tables.Add(dtNew);
该值存储在DataTable中,但选择查询DataTable的已提交版本。