By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,393 Members | 1,405 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,393 IT Pros & Developers. It's quick & easy.

Determining Column Number from Column Name

P: n/a

In .net2 using VB (Visual Web), I have the following code that properly
determines the column name from the column number (5 in this example) from a
single row table.

ColName = tempA.Table.Columns(5).ColumnName()

I can't figure out the code to return the column number if I have the column
name.

E.g., something like this:

ColNumber = tempA.Table.ColumnName(Y1).ColumnNumber()

Can someone point me in the right direction?

Thanks

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Dec 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Loop through the columns and do a If ....Then and if it equals the column
name you are looking for then you have your column number.
"Jeff" <no**@none.comwrote in message
news:45***********************@free.teranews.com.. .
>
In .net2 using VB (Visual Web), I have the following code that properly
determines the column name from the column number (5 in this example) from
a single row table.

ColName = tempA.Table.Columns(5).ColumnName()

I can't figure out the code to return the column number if I have the
column name.

E.g., something like this:

ColNumber = tempA.Table.ColumnName(Y1).ColumnNumber()

Can someone point me in the right direction?

Thanks

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Dec 24 '06 #2

P: n/a

"vbnetdev" <ad***@kjmsolutions.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Loop through the columns and do a If ....Then and if it equals the column
name you are looking for then you have your column number.

Thanks
After messing with this for a long while, I got the following to work.

CurColNumber = tempA.Table.Columns.IndexOf(ColName)

--
Posted via a free Usenet account from http://www.teranews.com

Dec 24 '06 #3

P: n/a
On Sun, 24 Dec 2006 09:04:43 -0600, Jeff wrote:
In .net2 using VB (Visual Web), I have the following code that properly
determines the column name from the column number (5 in this example) from a
single row table.

ColName = tempA.Table.Columns(5).ColumnName()

I can't figure out the code to return the column number if I have the column
name.

E.g., something like this:

ColNumber = tempA.Table.ColumnName(Y1).ColumnNumber()

Can someone point me in the right direction?

Thanks

Jeff
DataColumns have an Ordinal property. Could this be what you are looking
for?
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.