You can use the GetOrdinal property and assign it to a string. This way you
get the performance of the Index based approach with the readability of the
Literal name. like this...
DIM fieldCityPos as integer=reader1.getordinal("city")
Using the column slows things down because the column index needs to be
resolved each time a row is read...
HTH,
Bill
"lakshmi" <lm@newsgroup.net> wrote in message
news:89****************************@phx.gbl...
thanks a lot Ignacio. It worked.-----Original Message-----
Hi,
I do it all the time !
Did you tried it?
Just a comment, remember that you are getting the Item
property in this casethat is the indexer , therefore you have to write
reader["OrderNo"] using [] instead of ()
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"lakshmi" <lm@replytonewsgroup.net> wrote in message
news:03****************************@phx.gbl... Hi I'm using a SqlDataReader to read results from a SQL
view that returns 10 columns.
Is there anyway I can reader the columns based on their
names rather than their position?
strQuery = "SELECT customerid, orderno from orders where
orderID = 1";
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
myOrderNo = reader.GetInt32(1);
}
instead of using reader.GetInt32(1), is there any syntax
that will support reader("OrderNo") or something like that?
Thanks for your help.
.