我有以下代码我想在Datatable帮助中添加匹配数据。怎么做
private void GetVehicalIdFromWeb()
{
conn = new SqlConnection(Connection1);
conn.Open();
// var LIST=(from a in General.GetQueryable<Ve>)
string Query = "Select ID,Name from Vehicle ";
SqlDataAdapter ad = new SqlDataAdapter(Query, conn);
DataTable dt = new DataTable();
dtGetVihcale = new DataTable();
ad.Fill(dt);
var list = General.GetQueryable<Fleet_VehicleType>(c => c.VehicleType != null);
foreach (var item in list)
{
var rowsdata = from row in dt.AsEnumerable()
where row.Field<string>("Name").Trim() == item.VehicleType
select row;
dtGetVihcale = rowsdata.CopyToDataTable();
//dtGetVihcale = rowsdata.CopyToDataTable();
}
}
请看下面的图片我想一次只有一个记录 数据表如何通过数据表中的循环数据添加