在系统中dt获取urls并将它们放到getco ....函数中,然后我调用sql语句,然后将其添加到gridview数据源。但它获取最后一个url的项目,因此它覆盖。我如何解决它?如何添加多个语句到DataGridView数据源
for (int i = 0; i < dt.Rows.Count; i++)
{
row = dt.Rows[i];
GridView1.DataSource = db.getComboxedCombinedRSS(row[0].ToString());
}
GridView1.DataBind();
public DataSet getComboxedCombinedRSS(string url)
{
//SQL string to count the amount of rows within the OSDE_Users table
//string sql = "SELECT [RSS_Title], [RSS_ID], R.Syndication, R.Category FROM RSS AS R INNER JOIN CombinedFeeds AS C ON C.URL = R.URL WHERE C.Name='" +name+" ' ORDER BY RSS_Date desc";
string sql="SELECT top 30 [RSS_Title], [RSS_ID], Syndication, Category FROM RSS where URL= '"+url+"' order by RSS_DATE";
SqlDataAdapter adapt = new SqlDataAdapter(sql, Connect());
DataSet ds = new DataSet();
adapt.Fill(ds);
// result of query filled into datasource
adapt.Dispose();
closeConnection();
return ds;
}
乌尔循环覆盖它。处理 – nawfal
我该如何处理? – leventkalay92
只有leventkalay92可以做到这一点:)该机制应该是什么?将每个结果集添加到dgv?只保留第一个?保留一些,并忽略其余的?你只告诉我面临的麻烦,从来没有要求.. – nawfal