storing columns of database into hashtable.

  • Thread starter Thread starter trialproduct2004
  • Start date Start date
T

trialproduct2004

hi all

i want to store all values of particular table into hashtable. Say
suppose i have one table empployee with primary key as empid.
what i want is to store all empid into hashtable.

Does any one know how to it without inserting empid one by one.

Any help will be appreciated.

thanks in advance.
 
What's so hard about this?

foreach(DataRow row in myTable.Rows)
{
myHashtable.Add(row["EmpId"],row["EmpName"]);
}

Peter
 
Hi,


There is no way of doing this. a DataTable is a row oriented structure,
where you want to create a column based one, so the only way for doing it is
iterating in the rows and insert the values in the Hashtable


cheers,
 
Hi

thanks for your reply.

but i don't want to seperate copy of table in m,emory.

what i want is insteading of stroing values of table into datatable and
then from datatable to hashtable, directly from database to hashtable.

Is it possible?

any help will be truely appreciated.

thanks.
 
Back
Top