|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Accessing a field in untyped DSI 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 Ant,
output = dsCopy.Tables["orders"].Rows[0].Item["orderDate"].ToString(); > output = dsCopy.Tables[0].Rows[0][1].ToString();> //or > > //both should work assuming output is a string and that they exist.I hope this helps, Cor 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 > > > 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 >> >> >> Also, you don't need to call ToString() unless you want to get a value
converted to string. -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "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 >>> >>> >>> > > |
|||||||||||||||||||||||