🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database.dotnet
Article #644

Re: How do I loop around a dataset ?

#644
From: Viatcheslav V. Vassiliev
Date: Thu, 23 Sep 2004 12:54
92 lines
3959 bytes
You should not create DataRow - it could exist only inside DataTable:

var
    dbRow: DataRow;
begin
    dbRow := myDataTable.Rows[someIndex];
end;

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Claus Thor Barth" <ctb@NOSPAMbarth.dk> �������/�������� � ��������
���������: news:4152b899@newsgroups.borland.com...
> 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: <4152c773@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-mail
References: <413702a3$1@newsgroups.borland.com> <oi9ej09cdj7rjv8s67b2au1ea87kgp1dm0@4ax.com> <4152b899@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,86650b4da60f7bbe
X-Google-Attributes: gid1effe6,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.delphi.database.dotnet
References: <413702a3$1@newsgroups.borland.com> <oi9ej09cdj7rjv8s67b2au1ea87kgp1dm0@4ax.com> <4152b899@newsgroups.borland.com>
Subject: Re: How do I loop around a dataset ?
Date: Thu, 23 Sep 2004 16:54:08 +0400
Lines: 94
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 213.234.218.42
Message-ID: <4152c773@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1095944051 213.234.218.42 (23 Sep 2004 05:54:11 -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