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

GetValue

Is there any way to use GetValue on a sqldatareader.Read() by specifying
column names instead of column numbers (or another method)?
Nov 18 '05 #1
2 1016
I think you are looking for...

SqlDataReader reader;
....
if ( reader.Read() )
object value = reader["Column1"];
object value2 = reader["Column2"];
or VB style ( I think)

dim value as object = reader("Column1")
dim value2 as object = reader("Column2")

HTH,

bill

"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:3E**********************************@microsof t.com...
Is there any way to use GetValue on a sqldatareader.Read() by specifying
column names instead of column numbers (or another method)?

Nov 18 '05 #2
perfick! thanks

"William F. Robertson, Jr." wrote:
I think you are looking for...

SqlDataReader reader;
....
if ( reader.Read() )
object value = reader["Column1"];
object value2 = reader["Column2"];
or VB style ( I think)

dim value as object = reader("Column1")
dim value2 as object = reader("Column2")

HTH,

bill

"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:3E**********************************@microsof t.com...
Is there any way to use GetValue on a sqldatareader.Read() by specifying
column names instead of column numbers (or another method)?


Nov 18 '05 #3

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

Similar topics

5
by: Cezar | last post by:
Hi, I'm trying to get the value of a field in a class using Reflection. First of all, I can't access private fields. I know MSDN says you can access them if the code is fully trusted, but...
9
by: Joanna Carter \(TeamB\) | last post by:
Hi folks I am trying to assign a Delegate to an Event using reflection. I use FieldInfo.GetValue to supposedly get the field object, but casting the result to the type of the field and...
1
by: Byron | last post by:
I have a class that stores values of various types in public properties with private fields behind them. In addition to the field that is accessed through the public properties there is another...
2
by: Fuy | last post by:
Hi, i have a next problem: In the method startElement(const XMLCh* const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs ){
4
by: Prem | last post by:
This is what I am trying to do double utmx = (double) (pSqlReader.GetValue(pSqlReader.GetOrdinal("UTM_X83"))); and this is the exception that I get System.InvalidCastException was unhandled...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.