I am looking for opinions and best coding practices.
I need to get info from a database with a query such as SELECT this, that FROM MyDB
(returning 2 fields).
Would it be wrong to use a hashtable for temporary storage?
Is there a better way to accomplish the same thing?
What about if I am returning more than 2 fields, would it be best to step up to a
DataSet
or something?
I am looking for simple efficiency.
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetData();
foreach (DictionaryEntry de in ht)
{
DoSomething(Convert.ToInt32(de.Key), de.Value.ToString());
DoMore(Convert.ToInt32(de.Key), de.Value.ToString());
//etc...
}
}
Hashtable ht = new Hashtable();
private void GetData()
{
//connect to DB and use reader to fill hashtable ht with results..
}
private void DoSomething(int key, string value)
{
//do something with hashtable ht data
}
private void DoMore(int key, string value)
{
//do something else with hashtable ht data
}
}