Hi George,
What's the table name? "person"?
Have you tried this:
string name =dataSet11.Tables["person"].Rows[1]["firstName"].ToString();
or
string name =dataSet11.Tables[0].Rows[1]["firstName"].ToString();
You can use the following code to loop through the rows:
foreach(DataRow dr in dataSet11.Tables[0].Rows)
{
Console.WriteLine(dr["firstName"].ToString());
}
Regards,
Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: Accessing a Row in a typed Dataset
thread-index: AcPrMoSkof0TG5XoQ8GJ/tjKOYEBEw==
X-Tomcat-NG: microsoft.public.dotnet.general
From: "=?Utf-8?B?R2VvcmdlIEdyb2RlbnR6aWs=?=" <ge****@adsc.com>
Subject: Accessing a Row in a typed Dataset
Date: Wed, 4 Feb 2004 07:21:10 -0800
Lines: 7
Message-ID: <33**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:123664
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.general
I created a typed dataset from which I am trying to access the data. When
I use the following code to access a row:
string name =dataset.person[1].firstName;
I receive an error System.IndexOutOfRangeException as if there are no rows.
Yet when I dump the data to a file I receive (sample of file):
<?xml version="1.0" standalone="yes"?><Dataset1
xmlns="http://tempuri.org/Dataset1.xsd"><Table><accountNo>1</accountNo><firs
tName>John </firstName><lastName>Smith
</lastName><middleInitial></middleInitial></Table><Table><accountNo>2</accou
ntNo><firstName>Michael </firstName><lastName>Kimson
</lastName></Table><Table><accountNo>3</accountNo><firstName>Lewis
</firstName>
What am I doing wrong. How should I access the Rows of data in the dataset.
I also tried to loop through the rows with a foreach loop but apparently
there is no enumerator for this class.