473,386 Members | 1,764 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,386 software developers and data experts.

Column and dataset

Hello

I have this :

foreach (DataRow row in dataset.Tables[0].Rows)

{

....... //

}

In the loop how can I retrieve a specific column value but from the column
name and from the index ?

Regards,

Oct 8 '07 #1
4 1403
Each item in the DataColumns collection has a ColumnName property. You can
get these before you start the foreach.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Gabriel" wrote:
Hello

I have this :

foreach (DataRow row in dataset.Tables[0].Rows)

{

....... //

}

In the loop how can I retrieve a specific column value but from the column
name and from the index ?

Regards,

Oct 8 '07 #2
Each item in the DataColumns collection has a ColumnName property. You can
get these before you start the foreach.
It's not possible to do something like this (int the loop) :
row[0]["ColumnName"]

??

Thanks,

Oct 8 '07 #3
HTH

http://msdn2.microsoft.com/en-us/lib...arow.item.aspx

Thanks and Regards
Shishir Kumar Mishra

"Gabriel" <no****@nospam.comwrote in message
news:Os**************@TK2MSFTNGP05.phx.gbl...
Hello

I have this :

foreach (DataRow row in dataset.Tables[0].Rows)

{

...... //

}

In the loop how can I retrieve a specific column value but from the column
name and from the index ?

Regards,

Oct 8 '07 #4
Gabriel,

It is the Item property which is the default.

Therefore in C# you use it as you wrote, you can reference it with
an integer (the slowest) a string and the DataColumn as that is a property
from the Columncollection from the dataset. The latter is the fastest.

Cor

Oct 9 '07 #5

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

Similar topics

10
by: Robert Schuldenfrei | last post by:
Hi NG: I have the following code working. The GetProdStrtList() returns a DataTable called psTable. A Grid control is successfully bound to this table and displays correctly. I would like to...
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
3
by: JenHu | last post by:
I have a datagrid (dgFundStatus) which displays a column. When the Transmit_Date is null, how can I show "Not transmit yet" instead of null? Thanks. Sub BindData() Dim strSql As New...
1
by: louise raisbeck | last post by:
This sounds complicated but bear with me. I have a datagrid. It is dynamic in that, i dont know how many columns i will have until the dataset is back so i have to build the datagrid dynamically. I...
3
by: jason | last post by:
I'll try to explain in detail what it is I'm struggling with. I created a SQL database with one table called CallSheet which contains the following columns: Caller ID: <--Primary Key, auto...
1
by: ElenaR | last post by:
I need to figure out how to name my column headers in a DataGrid. In VB6, I could write DataGrid1.Columns(0).Caption = "ID". What is the format for VB.NET? Thanks in Advance!
16
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill...
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
5
by: Chris Botha | last post by:
There is a database table with one of the columns named "System". When creating a new Dataset for this table, the project gives a huge number of compile errors. If I change the column name to be...
4
by: Chris Botha | last post by:
The customer has a database with a column in a table named "System". I've been using this method for years now - create a dataset (an .xsd file) for the table. With a column named "System" in the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.