table
包含相同的列,gridview
根据datetime
降序排序。而且我要
要执行上述查询,请使用dataset
。dataview
和datatable
解决此问题的方法。
但是这个技巧在分类批量数据时失败了。这是我的代码..
ds2.Clear();
SqlDataAdapter getnewsfeeds;
SqlDataAdapter friendadapter = new SqlDataAdapter("select * from " + Session["username"].ToString() + "_friends ", friendscon);
friendadapter.Fill(friendsdataset);
int friendrowcount = friendsdataset.Tables[0].Rows.Count;
if (friendrowcount > 0)
{
for (int i = 0; i < friendrowcount; i++)
{
friendstringtable = " " + friendsdataset.Tables[0].Rows[i]["friendsusername"].ToString();
getnewsfeeds = new SqlDataAdapter("select top 5 * from " + friendstringtable + "_newsfeeds order by id desc", Newsfeedscon);
getnewsfeeds.Fill(ds2, "newsfeed");
}
}
getnewsfeeds.Fill(ds2, "newsfeed");
ds2.Tables["newsfeed"].DefaultView.Sort = "time_date desc";
DataView dv = ds2.Tables["newsfeed"].DefaultView;
dt = dv.ToTable();