473,598 Members | 3,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing a DataRow by name

Hello,

I´ve a problem with accessing the fields of a data row.

I created a row of my table "Metainfos" :

private fp_databaseData Set.MetainfosRo w newMetainfosRow ;

and then I can access for example the field "JournalNam e" in this
Metainfos-Table:

this.newMetainf osRow.JournalNa me
My question is now, if there is any solution to access the field with
using a variable like:

String field = "JournalNam e"

and then something like

this.newMetainf osRow.Field(fie ld)

or something like that.

Regards,

Martin
Aug 26 '06 #1
1 1349
Martin,

Yes, there is, you use the indexer, like this:

this.newMetainf osRow["JournalNam e"]

Note that you have to cast the return value to the type that you want,
in this case, it seems like a string, so you should do this:

string field = "JournalNam e"

string value = (string) this.newMetainf osRow[field];

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

"Martin Pöpping" <ma******@despa mmed.comwrote in message
news:ec******** **@newsreader2. netcologne.de.. .
Hello,

I´ve a problem with accessing the fields of a data row.

I created a row of my table "Metainfos" :

private fp_databaseData Set.MetainfosRo w newMetainfosRow ;

and then I can access for example the field "JournalNam e" in this
Metainfos-Table:

this.newMetainf osRow.JournalNa me
My question is now, if there is any solution to access the field with
using a variable like:

String field = "JournalNam e"

and then something like

this.newMetainf osRow.Field(fie ld)

or something like that.

Regards,

Martin

Aug 26 '06 #2

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

Similar topics

2
2245
by: George Grodentzik | last post by:
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.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><firstName>John ...
1
1311
by: Yama | last post by:
Hi, I have the following loaded into a dataset: <xml version="1.0" encoding="UTF-16"> <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"> <s:Schema id="RowsetSchema"> <s:ElementType name="row" content="eltOnly"
3
1510
by: shamila | last post by:
we are trying to pass a value to format a value in the datacolumn. But when we pass the datacolumn , it does not give me the value in the column, instead gives me the column name. the following code gives me an error invalid cast . protected void ItemDataBoundEventHandler(object sender,DataGridItemEventArgs e) { if(e.Item.ItemType==ListItemType.Item ||
3
1410
by: Darren Clark | last post by:
I am trying to understand typed datasets more.... and i am stuck on a little problem I have created a type dataset called "News" this consists of 2 tables. NewsTable and NewsTypes. the news has news_id int, title string and type int the news type table has type_id int and type_name string There is also a relationship created which is joining on the news.type and then newstype.type_id In the code below i am putting in 2 rows for...
0
1574
by: N. Demos | last post by:
Hello, I'm having problems accessing a complex XML child node (latitude & longitude), and passing it to a function when the XML file has been read into a DataSet. Specifically, the returned object from accessing the 'latitude' and 'longitude' nodes is not a DataTable (as specified in the MSDN). I'm not sure what type is being returned, nor how to go about finding out. Any pointers would be appreciated. Below is the relevent Error message,...
2
15366
by: paolol | last post by:
Hi, I wont to get the current row values from a dataset, any one know how to reach those data ?? At the moment I use a work around, but it's not good .. foreach (DataRow row in this.pitagoralavoriDataSet.Addetti.Rows) { if (Convert.ToString(row)== sNomeU){ idutente = Convert.ToInt32(row); }
1
2801
by: Arpan | last post by:
This is how I am dynamically adding a table to a DataSet: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) 'Create an empty DataSet Dim dSet As New DataSet 'Create a new table & add columns Dim dTable As New DataTable("Users") dTable.Columns.Add("ID", Type.GetType("System.Int32"))
2
2680
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I used the XML Designer to create an XML .XSD Schema to produce a Dataset. In looking for a way to start adding data to the dataset programmatically, i found this method in just about every thing i read.
4
1967
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to get to the correct DataSet values. <?xml version="1.0" encoding="utf-8" ?> <TestSample> <TRs> <TR1>
10
24162
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
0
7987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8397
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6718
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5850
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2412
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 we have to send another system
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.