开发者

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

开发者 https://www.devze.com 2022-12-09 00:25 出处:网络
I\'m using a stored procedure to create a temporary table and want to return it in a data collection:

I'm using a stored procedure to create a temporary table and want to return it in a data collection:

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

I don't know which data collection is best though to return. I might need to do some processing on it though so I'm not su开发者_JAVA技巧re what would be best, performance is not a major concern. I was thinking of a DataSet or DataReader but didn't know if there is anything better suited, or best practise. Any help is much appreciated

using .NET 2.0, vstudio 2005.

Thanks


DataTable is a common choice and works well for most things.

You can bind this guy to a GridView and get a lot of functionality right off the cuff.

  • Sorting
  • Custom styling
  • Paging
0

精彩评论

暂无评论...
验证码 换一张
取 消