473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Accessing a value from a dataset

Using c# I'm trying to access a value from a dataset using the following code.

keyword.Text = myDataSet.Tables[0].Columns["keyword"].ToString();

but rather than getting the value at that location I just get the value
'keyword'.
I've also tried this without success.

keyword.Text = myDataSet.Tables[0].Rows[0].ToString();
Nov 19 '05 #1
5 1161
keyword.text = mydataset.tables(0).rows(0).item(0).tostring()
"Protoculture" <Pr**********@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
Using c# I'm trying to access a value from a dataset using the following code.
keyword.Text = myDataSet.Tables[0].Columns["keyword"].ToString();

but rather than getting the value at that location I just get the value
'keyword'.
I've also tried this without success.

keyword.Text = myDataSet.Tables[0].Rows[0].ToString();

Nov 19 '05 #2
that wont work in c#

but this will, I found the answer....

keyword.Text = myDataSet.Tables[0].Rows[0].ItemArray[0].ToString();
Nov 19 '05 #3
On Thu, 08 Sep 2005 10:26:22 -0500, Protoculture
<Pr**********@discussions.microsoft.com> wrote:
that wont work in c#

but this will, I found the answer....

keyword.Text = myDataSet.Tables[0].Rows[0].ItemArray[0].ToString();


Note you could also just use brackets [] instead of parens () in the
previous answer's code. That's the only difference in syntax for this
statement....well, that and the ; at the end of each statement :)

--
craig
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #4
Note you could also just use brackets [] instead of parens () in the
previous answer's code. That's the only difference in syntax for this
statement....well, that and the ; at the end of each statement :)


Well actually the other difference is that Item(0) or Item[0] will not work
as well. It does not exist in c#. You need to use ItemArray ( which is crap
actaully ). Oh well.
=)
Nov 19 '05 #5
Just got it..

Label1.text = ds.Tables[0].Rows[0].ItemArray[3].ToString();
--
:: KHAMAL ::
"Protoculture" wrote:
Note you could also just use brackets [] instead of parens () in the
previous answer's code. That's the only difference in syntax for this
statement....well, that and the ; at the end of each statement :)


Well actually the other difference is that Item(0) or Item[0] will not work
as well. It does not exist in c#. You need to use ItemArray ( which is crap
actaully ). Oh well.
=)

Nov 19 '05 #6

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

Similar topics

2
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...
2
by: KimD | last post by:
I'm filling a dataset with the return of a stored procedure. The dataset contains a number of tables which I am naming within the stored procedure, however when I try to access the tables using the...
4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
3
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...
0
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...
0
by: Siegfried Heintze | last post by:
This program works fine on my desktop when I grant full control of the MSAccess database to everyone. However, when I put it on my hosting service with no impersonation, I now get this error (see...
5
by: nomail.thanks | last post by:
I apologize for the question in advance. I have lots of experience with lots of other languages, but now I'm trying to accomplish something with VB.NET Express. My experience with VB.NET express...
4
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...
2
by: Mike | last post by:
I have a SqlDataSource that returns a list of companies and their details by ProductID from a stored procedure. It also returns the name of the product associated with the ProductID as the final...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
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,...
0
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 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.