.net 获取获取list的值

var ShangJiaoRenShu = string.Format(@"select u.Code
from I_SalesForecast sf 
left join OT_User u on sf.CreatedBy=u.ObjectID
where sf.CreatedByParentId='{0}' and sf.CreatedTime>='{1}' and sf.CreatedTime<='{2}'", CreatedByParentId, Begin, End);
SqlConnection conn1 = new SqlConnection(ConnectionString);
conn1.Open();
SqlCommand comm = new SqlCommand(ShangJiaoRenShu, conn1);
SqlDataAdapter adapter = new SqlDataAdapter(comm);
DataSet ds = new DataSet();//datatable
adapter.Fill(ds);
var newTabel = ds.Tables[0];
//处理报错问题!
List<Dictionary<string, object>> list1 = new List<Dictionary<string, object>>();
foreach (DataRow dr in newTabel.Rows)//每一行信息,新建一个Dictionary<string,object>,将该行的每列信息加入到字典
{
Dictionary<string, object> result = new Dictionary<string, object>();
foreach (DataColumn dc in newTabel.Columns)
{
result.Add(dc.ColumnName, dr[dc].ToString());
}
list1.Add(result);
}

 

foreach (var item in list1)
{
UserName2 += item.ToString();
}

 

list1里有4个值 分别是 王金龙 赵海伟 王楠 孟岩 请问我怎么把这4个值赋给UserName2


Qyouu
浏览 809回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP