簡體   English   中英

asp.net:應使用哪個數據收集來返回表

[英]asp.net: which data collection should be used to return a table

我正在使用存儲過程創建一個臨時表,並希望在數據收集中返回它:

public static >>data collection<< reportData(int intUserID)    
{
SqlConnection con = Sql.getConnection();

                try
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd = new SqlCommand("usp_Get_Results", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserID", intUserID);
                    con.Open();
                    //put into data collection
                    //return data collection
                }
                catch (Exception ex)
                {
                    //Log Error
                    con.Close();
                }
                finally
                {
                    con.Close();
                }
}

我不知道最好返回哪個數據收集。 不過,我可能需要對其進行一些處理,因此我不確定哪種方法最好,性能不是主要問題。 我當時在考慮使用DataSet或DataReader,但不知道是否有更適合的方法或最佳實踐。 任何幫助深表感謝

使用.NET 2.0,vstudio 2005。

謝謝

DataTable是常見的選擇,適用於大多數情況。

您可以將此人綁定到GridView並立即獲得很多功能。

  • 排序
  • 自定義樣式
  • 分頁

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM