Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataSet column values

Status
Not open for further replies.

wallaceoc80

Programmer
Joined
Jul 7, 2004
Messages
182
Location
GB
I'm using a DataSet to retrive data from a Database and access the values of the columsn returned. I then want to set the Text of various labels to the values of the columns. To do this I use to code below

Code:
appID.Text = dsAppData.Tables[0].Columns[0].ToString();
appName.Text = dsAppData.Tables[0].Columns[1].ToString();
gripsID.Text = dsAppData.Tables[0].Columns[2].ToString();

The problem is that it sets the text of the labels to the column names and not the values. Am I using the wrong code?

Thanks,

Wallace
 
use:
appID.Text = dsAppData.Tables[0].Columns[0]("Column name")
 
Sorry, should use:
appID.Text = dsAppData.Tables[0].rows[0]("Column name")
 
Tried this but it does not work. I get an error. Is this code c# or for VB? I'm writing in C# if this makes any difference to you.

Thanks again,

Wallace
 
I should have said that when I use the syntax provided by you the error I get is:

Method Expected

Regards,

Wallace
 
in help, index, type "cells, changing DataGrid cell values
 
appID.Text = (string)dsAppData.Tables[0].Rows[0][0];

This gets the first column in the first row of the first table. This is returned as an object so you have to cast it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top