2012-05-03 9 views
0

システムでは、dtがurlsを取得し、そこにgetco .... functionを配置します。次に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; 
} 
+0

ウルループは、それを上書きしています。その – nawfal

+0

をどうすれば処理できますか? – leventkalay92

+0

leventkalay92のみがそうすることができます:)どのようなメカニズムが必要ですか?各結果セットをdgvに追加しますか?最初のものだけを保つ?少数を保ち、残りを無視するか?あなたは唯一の問題は、要件を決して直面している問題を語っている.. – nawfal

答えて

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(); 

} 
+0

ありがとうが、それは2番目を追加しないので、他のステートメントは動作しません? – leventkalay92

+0

RSS_IDはRSS_DATEの主キーですか? –

+0

las編集を試してください –

関連する問題