Article View: borland.public.delphi.database.dotnet
Article #643Re: How do I loop around a dataset ?
From: Claus Thor Barth
Date: Thu, 23 Sep 2004 11:46
Date: Thu, 23 Sep 2004 11:46
71 lines
3160 bytes
3160 bytes
Hi again,
This works fine in C# but in Delphi I am having trouble declaring a DataRow:
> DataRow oMyWorkRow := myDataTable.Rows[someIndex];
var
dbRow : DataRow;
Begin
dbRow := DataRow.Create;
...
End;
This is not working. Should I declare a DataRow in another way ?!?
Thanks in advance
/Claus
ctb(at)barth(dot)dk
"Marc Scheuner" <no.spam@for.me> wrote in message
news:oi9ej09cdj7rjv8s67b2au1ea87kgp1dm0@4ax.com...
> >In good "old" Delphi it was very easy to loop around a dataset, but how
> >do I
>>do it in .NET
>>All the commands I used to know about aren't there anymore (first, next,
>>recordcount and so on).
>
> A dataset in .NET actually is just a container for a number of
> DataTables, and a few auxiliary constructs (like relations between
> those tables).
>
> You cannot loop through the data set per se - you will need to use a
> DataTable contain in that data set, and loop through that.
>
> The DataSet contains a collection called "Tables" - have a look. You
> can find out how many tables are contained in your DataSet by
> inspecting DataSet.Tables.Count, and for each table, you can then look
> at the data contained in that table.
>
> for ix := 0 to myDataSet.Tables.Count-1 do begin
> Console.WriteLine('Table no. ' + ix.ToString + ' is called ' +
> myDataSet.Tables[ix].TableName);
> end;
>
> The data in that table is organized in columns (the "fields" of the
> data table), and rows - both of which incidentally are properties of
> the DataTable.
>
> To enumerate all data rows, you would simply see how many there are
> (DataTable.Rows.Count), and then step through those one by one as in
> an array
>
> DataRow oMyWorkRow := myDataTable.Rows[someIndex];
>
> Each row then contains every field and its values:
>
> oMyWorkRow['SomeFieldName'].Value
>
> should give you access to the values in your current DataRow, for that
> given column (or field).
>
> Does that help at all??
>
> Marc
>
> ================================================================
> Marc Scheuner May The Source Be With You!
> Bern, Switzerland m.scheuner(at)inova.ch
Technical Details
Message-ID:
<4152b899@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<413702a3$1@newsgroups.borland.com> <oi9ej09cdj7rjv8s67b2au1ea87kgp1dm0@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,86650b4da60f7bbe X-Google-Attributes: gid1effe6,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Claus Thor Barth" <ctb@NOSPAMbarth.dk> Newsgroups: borland.public.delphi.database.dotnet References: <413702a3$1@newsgroups.borland.com> <oi9ej09cdj7rjv8s67b2au1ea87kgp1dm0@4ax.com> Subject: Re: How do I loop around a dataset ? Date: Thu, 23 Sep 2004 13:46:57 +0200 Lines: 73 X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 195.184.124.164 Message-ID: <4152b899@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095940249 195.184.124.164 (23 Sep 2004 04:50:49 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail