Home All Groups Group Topic Archive Search About

Accessing a field in untyped DS

Author
29 Jan 2006 4:48 AM
Ant
Hello,
I have an copied data set. I'm trying to access a field.

daOrder.Fill(dsOrderSheet);

DataSet dsCopy = new DataSet();

dsCopy = dsOrderSheet.Copy();

// How do you do this part?

output = dsCopy.Tables["orders"].Rows[0].ItemArray["orderDate"];

//or

output = dsCopy.Tables[0].Rows[0].ItemArray[1];

//neither work.

How is this done?

Thanks kindly for any advice on this
Ant

Author
29 Jan 2006 8:30 AM
Cor Ligthert [MVP]
Ant,

output = dsCopy.Tables["orders"].Rows[0].Item["orderDate"].ToString();
>
> //or
>
output = dsCopy.Tables[0].Rows[0][1].ToString();
>
//both should work assuming output is a string and that they exist.

I hope this helps,

Cor
Author
29 Jan 2006 9:17 AM
Ant
Hi Cor,

as always, thanks for your help. I tried the string you supplied:

output = dsCopy.Tables["orders"].Rows[0].Item["orderDate"].ToString();

by both typing it in & pasting it in, however I get a compile error as it
doesn't recognize .Item as an existing collection. (Intellisense only offers
up an ItemArray collection.)

Is this because I'm using VS2003?

Thanks for your help
Ant


Show quote
"Cor Ligthert [MVP]" wrote:

> Ant,
>
> > >
> > //or
> >
>  output = dsCopy.Tables[0].Rows[0][1].ToString();
> >
> //both should work assuming output is a string and that they exist.
>
> I hope this helps,
>
> Cor
>
>
>
Author
29 Jan 2006 10:11 AM
Cor Ligthert [MVP]
Ant,

Sorry this overloaded version is not in C# only in VB.Net, I was automaticly
expecting it was the same. So you would have to do it with the other sample.

To be sure did I try it in C#, the documentation is a little bit vague about
this.

I hope this helps,

Cor


Show quote
"Ant" <A**@discussions.microsoft.com> schreef in bericht
news:D18E783F-4288-4D20-A40F-532D9DDA5F9C@microsoft.com...
> Hi Cor,
>
> as always, thanks for your help. I tried the string you supplied:
>
> output = dsCopy.Tables["orders"].Rows[0].Item["orderDate"].ToString();
>
> by both typing it in & pasting it in, however I get a compile error as it
> doesn't recognize .Item as an existing collection. (Intellisense only
> offers
> up an ItemArray collection.)
>
> Is this because I'm using VS2003?
>
> Thanks for your help
> Ant
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Ant,
>>
>> > >
>> > //or
>> >
>>  output = dsCopy.Tables[0].Rows[0][1].ToString();
>> >
>> //both should work assuming output is a string and that they exist.
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>>
Author
29 Jan 2006 11:19 AM
Miha Markic [MVP C#]
Also, you don't need to call ToString() unless you want to get a value
converted to string.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:epyLJxLJGHA.216@TK2MSFTNGP15.phx.gbl...
> Ant,
>
> Sorry this overloaded version is not in C# only in VB.Net, I was
> automaticly expecting it was the same. So you would have to do it with the
> other sample.
>
> To be sure did I try it in C#, the documentation is a little bit vague
> about this.
>
> I hope this helps,
>
> Cor
>
>
> "Ant" <A**@discussions.microsoft.com> schreef in bericht
> news:D18E783F-4288-4D20-A40F-532D9DDA5F9C@microsoft.com...
>> Hi Cor,
>>
>> as always, thanks for your help. I tried the string you supplied:
>>
>> output = dsCopy.Tables["orders"].Rows[0].Item["orderDate"].ToString();
>>
>> by both typing it in & pasting it in, however I get a compile error as it
>> doesn't recognize .Item as an existing collection. (Intellisense only
>> offers
>> up an ItemArray collection.)
>>
>> Is this because I'm using VS2003?
>>
>> Thanks for your help
>> Ant
>>
>>
>> "Cor Ligthert [MVP]" wrote:
>>
>>> Ant,
>>>
>>> > >
>>> > //or
>>> >
>>>  output = dsCopy.Tables[0].Rows[0][1].ToString();
>>> >
>>> //both should work assuming output is a string and that they exist.
>>>
>>> I hope this helps,
>>>
>>> Cor
>>>
>>>
>>>
>
>

AddThis Social Bookmark Button