Article View: borland.public.csharpbuilder.language.csharp
Article #277Re: DataSet FieldByName ?
From: Marc Rohloff TeamB
Date: Wed, 21 Dec 2005 01:50
Date: Wed, 21 Dec 2005 01:50
21 lines
1871 bytes
1871 bytes
On Tue, 20 Dec 2005 21:19:09 +0800, Rise wrote:
> In Delphi you can do TDataSet.FieldByName('mycolumn') and it returns the
> value for that column.
> Is there their an equivalent for this in C# ?
I'll start by assuming that you are asking about a DataTable since
that is the closest thing .NET has to a TDataset. Also don't forget
that DataTable's don't have the concept of a current row like TDataset
does. Usually you just do:
table.Rows[currentRow]["ID"]
or
table.Rows[currentRow][3]
You would then just typecast to the type you are expecting:
int id = (int)table.Rows[currentRow]["ID"]
--
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Technical Details
Message-ID:
<1r7kyofrs3yzd.dlg@marcrohloff.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43a80473$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,40ad613e8137d362 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: DataSet FieldByName ? Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <43a80473$1@newsgroups.borland.com> Date: Tue, 20 Dec 2005 20:50:22 -0500 Message-ID: <1r7kyofrs3yzd.dlg@marcrohloff.com> X-Face: "huzh55Xi]!ZNni78>a*5+).`SK?<^q2MlHk-C]Z2M9T@\J5ZCB$95Ey+s"XQuhGFA[eutZ :0^AV!Q;t>gE`1-=8d;HZ6~*o1dH<X9\b$!|(}+I'!Xq)@3Op}%0ArW&nf'Qh*EwR X-Antivirus: avast! (VPS 0551-2, 12/20/2005), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 65.31.9.204 X-Trace: newsgroups.borland.com 1135129657 65.31.9.204 (20 Dec 2005 17:47:37 -0700) Lines: 21 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail