Datasets

B

brian

I need help creating a dataset with a SQL string and help
iterating through it or querying the dataset.

I am really getting confused with the datatable. When
creating a dataset are you filling a datatable?

For example: Fill the dataset with employee names and
position. With that I want to know the employees who's
position = 'Manager'

Thanks

I always use a datareader for my needs but am starting to
run into problems with the connection issue. I need to
connections open and the datareader will only allow 1.
So I guess it's time to learn more about datasets.
 
A

Alvin Bruney

Actually, the table is what gets filled with the information, not the
dataset. When you assign to a dataset, you are actually assinging to the
default table. So the table holds the information. The dataset holds the
table or a collection of tables because it is possible to have more than one
table in the dataset.

Knowing that, to retrieve the information, you would have to iterate the
thru the table. Actually thru what makes up the table. A table is made up of
rows, so you examine the rows one at a time looking for the value or you can
use the find method which typically returns the culprit row.

Start with a for loop where ds is my dataset and i'm wanting to examine
table 0 which is the first table.
for(int index = 0; index < ds.Tables[0].Rows.Count; index++)

if(ds.Tables[0].Rows[index][1].ToString() == "Manager")

i'm using index 1 here because i assume my query looks like this select
employee,position ...

if i were looking for employee, i'd change my index to 0 instead of 1.

make sense?
 

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

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top