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
精彩评论