UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Datarow.item Property Is Missing? Vcs2010    
 
   
jleach
post Jan 8 2011, 07:15 AM
Post #1

UtterAccess Editor
Posts: 6,726
From: Capital District, NY, USA



Hi,

Apparently for the DataRow class there's supposed to be an Item property (with 6 overloads) that can be used to access columns,but I don't seem to have it. I've checked the MSDN and can't seem to find any reason that it would not be available (.NET 4, ADO.NET 4, MSDN DataRow Class documentation for .NET 4).

It doesn't show up in intellisense, and if I manually force it in there, I get the following error:

QUOTE
'System.Data.DataRow' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.DataRow' could be found (are you missing a using directive or an assembly reference?)


Any ideas? I've been able to work around not having it, but it'd be handy...

Thanks,
Go to the top of the page
 
+
ALaRiva
post Jan 10 2011, 11:30 AM
Post #2

UtterAccess VIP
Posts: 7,132
From: Perris, California



That's because VB considers it a property, when in actuality, it is an indexer of the class. And since you are using C#, it does it the right way.

So you would access it like an array.

myRow[1] = "Blah blah";

hth
- Anthony
Go to the top of the page
 
+
jleach
post Jan 10 2011, 11:37 AM
Post #3

UtterAccess Editor
Posts: 6,726
From: Capital District, NY, USA



>>myRow[1] = "Blah blah";<<

That's what I generally use, but it doesn't accept any overloaded arguments this way, which would be nice if not a necessity. Again, all that can be worked around by specifically setting the other properties, but utilizing the overloads would be handy.

In any case, thanks for the reply... at least I have some idea why it's not there now. It was more of a 'why not' question than 'I need the overload functionality' question.

Interesting that the MSDN doesn't make some mention of that, or at least not where I was looking.

Cheers,
Go to the top of the page
 
+
ALaRiva
post Jan 10 2011, 11:43 AM
Post #4

UtterAccess VIP
Posts: 7,132
From: Perris, California



Can you post code of how you are attempting to use it?
Go to the top of the page
 
+
jleach
post Jan 10 2011, 12:00 PM
Post #5

UtterAccess Editor
Posts: 6,726
From: Capital District, NY, USA



Just taking some notes in a cs file from an ADO book I picked up. It's supposed to return a specific version of the datarow before an update:

myRow(123, DataVersionRow.Proposed)

Go to the top of the page
 
+
ALaRiva
post Jan 10 2011, 12:07 PM
Post #6

UtterAccess VIP
Posts: 7,132
From: Perris, California



QUOTE (jleach @ Jan 10 2011, 10:00 AM) *
Just taking some notes in a cs file from an ADO book I picked up. It's supposed to return a specific version of the datarow before an update:

myRow(123, DataVersionRow.Proposed)

I don't see anything in there trying to access the index, e.g. []

What is myRow? Is that a method? I'm not seeing how this ties to your issue, or maybe I'm just having the mondays.

Can you show full code, or at least a little more? Where does the 123 come from?

Thanks.
Go to the top of the page
 
+
ALaRiva
post Jan 10 2011, 12:14 PM
Post #7

UtterAccess VIP
Posts: 7,132
From: Perris, California



Did you mean...

CODE
myRow[123, DataVersionRow.Proposed]


Looks like maybe just a case of overlooking the character used?
Go to the top of the page
 
+
jleach
post Jan 10 2011, 12:17 PM
Post #8

UtterAccess Editor
Posts: 6,726
From: Capital District, NY, USA



Sorry, those were supposed to be square brackets instead of parentheses.

There is no "full code", persay... just syntax notes I'm keeping in a file as I work through the book. It makes for easy (color coded) reference for when I start 'actually' using them and forget the syntax (if notepad color coded the same as VS I'd keep it there). 123 was just an example of 'some index'.
Go to the top of the page
 
+
ALaRiva
post Jan 10 2011, 12:20 PM
Post #9

UtterAccess VIP
Posts: 7,132
From: Perris, California



That's weird that it won't work. I only have VS 2002 (first edition, no updates, (IMG:style_emoticons/default/frown.gif) ) here at work, but maybe tonight when I get home I'll check.

I can't remember hitting this issue.
Go to the top of the page
 
+
jleach
post Jan 10 2011, 12:28 PM
Post #10

UtterAccess Editor
Posts: 6,726
From: Capital District, NY, USA



This is from VS 2010 Express... the original post was from the install at my house, which give the original error, this is a seperate installation at work. Maybe it's some bug with Express that they didn't get around to fixing.

I might send a bug report if there doesn't seem to be any solution. Come to think of it, I'm not sure we can get around this without having the overload. There is now "version" property of the DataRow class which returns that particular version of the row... this seems to be the only way to do it, in which case, I'd be screwed if I needed it...
Attached File(s)
Attached File  err.JPG ( 35.29K ) Number of downloads: 8
 
Go to the top of the page
 
+
datAdrenaline
post Feb 15 2011, 11:14 PM
Post #11

UtterAccess Editor
Posts: 16,032
From: Northern Virginia, USA



Jack,

This is not a bug, your code pictured is in error ...

You have:
tblMedia.Rows[0, DataRowVersion.Original]

So you are passing 2 arguments to the Rows collection ... and the Rows collection does not have an overload like you have specified, just like the error says.


You are wanting to use an overload for a single item of the Rows collection (a DataRow), so you must specify the row object you wish to work with. Your code should be ...

tblMedia.Rows[0][0, DataRowVersion.Original]
Go to the top of the page
 
+
datAdrenaline
post Feb 15 2011, 11:18 PM
Post #12

UtterAccess Editor
Posts: 16,032
From: Northern Virginia, USA



As a side note the pretzel you wound up in is often remedied by declaring an object variable ...

DataRow dr = tblMedia.Rows[0]

If dr.HasVersion .. blah ... blah ...

If dr[0, DataRowVersion.Orginal] ... blah ... blah...
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 01:31 PM