Datatable/Hashtable Question

G

Guest

I have the following code which allows me to display records from a table
named "lkup_Specie" in a datagrid. If I create a second datatable and a
second hashtable for a table named "lkup_Grade", how would I incorporate that
logic into my existing logic? Would it go after Next statement? Thanks.

Protected specieDataTable As New DataTable 'BEING USED OK
Protected specieHashTable As New Hashtable 'BEING USED OK
Protected cutDataTable As New DataTable 'NEED TO INCORPORATE THIS
Protected cutHashTable As New Hashtable 'NEED TO INCORPORATE THIS

Dim adapter As New SqlDataAdapter("SELECT * FROM lkup_Specie",
SQLConnection1)
adapter.Fill(specieDataTable)
'Also populate a Hashtable, which is easier for the databinding
expression.
Dim dr As DataRow
For Each dr In specieDataTable.Rows
specieHashTable.Add(dr("SpecieID"), dr("Specie"))
Next
 
J

jjardine

MrMike said:
I have the following code which allows me to display records from a table
named "lkup_Specie" in a datagrid. If I create a second datatable and a
second hashtable for a table named "lkup_Grade", how would I incorporate
that
logic into my existing logic? Would it go after Next statement? Thanks.

Protected specieDataTable As New DataTable 'BEING USED OK
Protected specieHashTable As New Hashtable 'BEING USED OK
Protected cutDataTable As New DataTable 'NEED TO INCORPORATE THIS
Protected cutHashTable As New Hashtable 'NEED TO INCORPORATE THIS

Dim adapter As New SqlDataAdapter("SELECT * FROM lkup_Specie",
SQLConnection1)
adapter.Fill(specieDataTable)
'Also populate a Hashtable, which is easier for the databinding
expression.
Dim dr As DataRow
For Each dr In specieDataTable.Rows
specieHashTable.Add(dr("SpecieID"), dr("Specie"))
Next

Are you just trying to get one trip to the database?? you dould do
something like this..

Protected ds as New DataSet()

Dim adapter as New SqlDataAdapter("SELECT fields FROM lkup_Specie;SELECT
fields FROM lkup_Grade",SQLConnection1)
adapter.Fill(ds)

Dim dr as DataRow
For Each dr In ds.Tables(0).Rows
specieHashTable.Add(dr("SpecieID"), dr("Specie"))
Next

For Each dr In ds.Tables(1).Rows
cutHashTable.Add(dr("field"), dr("field))
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top