469,642 Members | 1,254 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

Datatable/Hashtable Question

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
Jul 21 '05 #1
1 4738

"MrMike" <Mr****@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
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
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by _eee_ | last post: by
5 posts views Thread by francois | last post: by
2 posts views Thread by Guadala Harry | last post: by
1 post views Thread by MrMike | last post: by
4 posts views Thread by =?Utf-8?B?UmljaA==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.