2009-10-18 8 views
1

我使用一個存儲過程創建一個臨時表,並希望在數據採集返回它:asp.net:數據收集應使用返回表

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

感謝

回答

1

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

你可以將這個人綁定到GridView,並從袖口獲得很多功能。

  • 排序
  • 自定義造型
  • 尋呼