473,513 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Easy DataSet question

I know I am missing something simple here. I have tried looking on Google
for a solution, but can't seem to do it. What is wrong with my code...?

foreach (DataRow myRow in yy.Tables[0].Rows)
{
MessageBox.Show((string)yy.Tables[0].Rows[myRow]["name"].ToString());
}

My goal is to MessageBox for each item in the "name" row.
Nov 16 '05 #1
2 955
Keith,

When you enumerate through the rows, the enumeration returns the row,
not the indexer for the row. Because of that, you can just do this:

foreach (DataRow myRow in yy.Tables[0].Rows)
{
MessageBox.Show((string) myRow["name"]);
}

You don't need to call ToString on the return value of the indexer for
myRow if the type is a string, you can just cast it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Keith Smith" <ke*********@verizon.net> wrote in message
news:eiLNd.10858$uc.3615@trnddc05...
I know I am missing something simple here. I have tried looking on Google
for a solution, but can't seem to do it. What is wrong with my code...?

foreach (DataRow myRow in yy.Tables[0].Rows)
{
MessageBox.Show((string)yy.Tables[0].Rows[myRow]["name"].ToString());
}

My goal is to MessageBox for each item in the "name" row.

Nov 16 '05 #2
foreach (DataRow myRow in yy.Tables[0].Rows)
{
Messagebox(myRow["name"].ToString());
}

Yoa already have the row in myRow
"Keith Smith" wrote:
I know I am missing something simple here. I have tried looking on Google
for a solution, but can't seem to do it. What is wrong with my code...?

foreach (DataRow myRow in yy.Tables[0].Rows)
{
MessageBox.Show((string)yy.Tables[0].Rows[myRow]["name"].ToString());
}

My goal is to MessageBox for each item in the "name" row.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1305
by: CLEAR-RCIC | last post by:
How would I get at a certain piece of data in a dataset. For example, how would I specify first row, first column. What seems logical to me doesn't work. Dim strResult as String =...
2
1188
by: Roger | last post by:
I am using visual studio 2003. I user the server explorer and drag a table onto a webform. The program creates a "Connection" and an SQLDataAdapter Generates the "Select, Insert, Delete"...
5
263
by: CLEAR-RCIC | last post by:
How would I get at a certain piece of data in a dataset. For example, how would I specify first row, first column. What seems logical to me doesn't work. Dim strResult as String =...
10
1621
by: cj | last post by:
I have lots of tables to copy from one server to another. The new tables have been created to match the old ones. I practiced with one table. I created the select command (select * from tableA)...
1
272
by: Frankz | last post by:
Hi, I am new to this group so forgive me if this question sounds too newbie. :-) I am writing a C# program. One of its functionalities is to use a .Net dataset to create and populate a table in...
0
7388
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
7545
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...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5095
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...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.