문제

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 sure 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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top