0

在系统中,dt 获取 url,然后将它们放入 getco.... 函数中,然后调用 sql 语句,将其添加到 gridview 数据源。但它会获取最后一个 url 的项目,因此它会覆盖。我该如何解决?

     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;
}
4

1 回答 1

0
 DataSet ds = new DataSet();
 for (int i = 0; i < dt.Rows.Count; i++)
     {
         row = dt.Rows[i];
        db.getComboxedCombinedRSS( row[0].ToString(), ds);
     }
     GridView1.DataSource = ds;
     GridView1.DataBind();




public void getComboxedCombinedRSS(string url, DataSet ds)
{
    //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());

    adapt.Fill(ds);

    // result of query filled into datasource
    adapt.Dispose();

    closeConnection();

}
于 2012-05-03T23:17:16.870 回答