I'm a VB.net programmer currently battling to build new apps in C#, and MAN!
It's been a bit frustrating, to say the least.
I've done quite a bit of progamming with Java and C back in the day, so I
can deal with the case sensitiviness and semicolens, but I'm finding certain
aspects of the language to be a real pain.
Well, to get to the point, here's a problem that I'd appreciate it if
someone could help me...
Note: dsResponse is a dataset being populated by an xml file.
In code, I have the following:
//This works:
if (dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
== "Fail")
//This doesn't work
if (dsResponse.ReservationResponse.Rows[0].ItemArray["Status"] == "Fail")
error: Cannot implicitly convert type 'string' to 'int'
In the command window:
//this works
dsResponse.ReservationResponse.Rows[0].ItemArray["Status"]
//this DOESN'T:
dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString()
Error:
'dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0.ToString' does
not exist
What I would like to accomplish is to be able to use the NAME of the field,
and not the index value, to retrieve the value of that item.
WHAT GIVES?
tia 2 2943
tuuky <tu***@discussions.microsoft.com> wrote: I'm a VB.net programmer currently battling to build new apps in C#, and MAN! It's been a bit frustrating, to say the least.
I've done quite a bit of progamming with Java and C back in the day, so I can deal with the case sensitiviness and semicolens, but I'm finding certain aspects of the language to be a real pain.
Well, to get to the point, here's a problem that I'd appreciate it if someone could help me...
Note: dsResponse is a dataset being populated by an xml file.
In code, I have the following: //This works: if (dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString() == "Fail")
//This doesn't work if (dsResponse.ReservationResponse.Rows[0].ItemArray["Status"] == "Fail") error: Cannot implicitly convert type 'string' to 'int'
Indeed, because you can't index an array (ItemArray) by string. I don't
know why you're using the ItemArray property anyway though - why not
just use the indexer on the row itself?
In the command window: //this works dsResponse.ReservationResponse.Rows[0].ItemArray["Status"]
That sounds very odd. Are you sure you don't mean
dsResponse.ReservationResponse.Rows[0]["Status"]
?
//this DOESN'T: dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString() Error: 'dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0.ToString' does not exist
What I would like to accomplish is to be able to use the NAME of the field, and not the index value, to retrieve the value of that item.
So use
if (dsResponse.ReservationResponse.Rows[0]["Status"]=="Fail")
{
....
}
No problem.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks a lot, Jon.
Part of the growing pains, I guess.
"Jon Skeet [C# MVP]" wrote: tuuky <tu***@discussions.microsoft.com> wrote: I'm a VB.net programmer currently battling to build new apps in C#, and MAN! It's been a bit frustrating, to say the least.
I've done quite a bit of progamming with Java and C back in the day, so I can deal with the case sensitiviness and semicolens, but I'm finding certain aspects of the language to be a real pain.
Well, to get to the point, here's a problem that I'd appreciate it if someone could help me...
Note: dsResponse is a dataset being populated by an xml file.
In code, I have the following: //This works: if (dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString() == "Fail")
//This doesn't work if (dsResponse.ReservationResponse.Rows[0].ItemArray["Status"] == "Fail") error: Cannot implicitly convert type 'string' to 'int'
Indeed, because you can't index an array (ItemArray) by string. I don't know why you're using the ItemArray property anyway though - why not just use the indexer on the row itself?
In the command window: //this works dsResponse.ReservationResponse.Rows[0].ItemArray["Status"]
That sounds very odd. Are you sure you don't mean
dsResponse.ReservationResponse.Rows[0]["Status"]
?
//this DOESN'T: dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0).ToString() Error: 'dsResponse.ReservationResponse.Rows[0].ItemArray.GetValue(0.ToString' does not exist
What I would like to accomplish is to be able to use the NAME of the field, and not the index value, to retrieve the value of that item.
So use
if (dsResponse.ReservationResponse.Rows[0]["Status"]=="Fail") { .... }
No problem.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Al Davis |
last post by:
Note: I tried cross-posting this message to several newsgoups,
including comp.lang.perl.misc, c.l.p.moderated,
comp.infosystems.www.authoring.cgi, comp.lang.javascript and
comp.lang.php. Nothing...
|
by: thecrow |
last post by:
Alright, what the hell is going on here?
In the following code, I expect the printed result to be:
DEBUG: frank's last name is burns.
Instead, what I get is:
DEBUG: frank's last name is...
|
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: Brandon J. Van Every |
last post by:
I'm realizing I didn't frame my question well.
What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump
up in your chair and scream "Wow! Ruby has *that*? That is SO...
|
by: Chris Cioffi |
last post by:
I started writing this list because I wanted to have definite points
to base a comparison on and as the starting point of writing something
myself. After looking around, I think it would be a...
| |
by: Reed L. O'Brien |
last post by:
I see rotor was removed for 2.4 and the docs say use an AES module
provided separately... Is there a standard module that works alike or
an AES module that works alike but with better encryption?...
|
by: Philippe C. Martin |
last post by:
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).
- 1) I do not consider my intelligence/education above average
- 2) I am very...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: Midnight Java Junkie |
last post by:
Dear Colleagues:
I feel that the dumbest questions are those that are never asked. I have
been given the opportunity to get into .NET. Our organization has a
subscription with Microsoft that...
|
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,...
| |
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |