473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 4906

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bpdace | last post by:
I have a datasource that is being passed in as a Hashtable. I want to load in all the Values (strings inside the Value, not the Keys) into a collumn inside a DataTable. The values need to be sorted...
3
by: _eee_ | last post by:
I have been using a HashTable to store name/value pairs, but now I need to add a third element (name/value/flag). I still need to be able to index by , and I'd like to keep lookup speed as high...
5
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
2
by: Guadala Harry | last post by:
The current implementation (that works) retrieves data from a SS2K db via stored procedure that returns 40-60 rows and 6 columns (one string and five int columns), and places that result set into a...
1
by: M | last post by:
My problem is that AutogenerateColumns="false" does not work with the datatable I built from a hashtable. (Please don't ask why I'm pulling data from a database, putting it in a hashtable, then...
3
by: Bob | last post by:
I have a name-value pair type of data that I need to search against. It's to determine what menu item to highlight given the asp.net page name. So the list has all my page names (unique) and the...
1
by: MrMike | last post by:
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",...
4
by: Rich | last post by:
Hello, I need to store various values that I will need to look up later on. I have been using hashtables and arraylists. But I can only store 2 items per row in a hashtable - key, value, and...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, In my vb2005 app I create 3 datatables in the Datasource area, tbl1, tbl2, tbl3. tbl1 contains 1 column, tbl2 contains 2 columns tbl3 contains 3 columns. Based on selections from a...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.