[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I couldn't get the value of a column at a specific ordinal from a datareader.

Posted on 2008-06-09
3
Medium Priority
?
161 Views
Last Modified: 2010-04-23
Something worked for me the last time around ---  myrow(mycold1) = autoreader.GetValue(2)
but now, it,autoreader.getvalue(2), only return the column name.  
What I want is the content of the datareader's column returned from a datareader.read() method.
If I try to use datareader.getstring(2), I got a 'cast' exception.

Using autoreader As System.Data.OleDb.OleDbDataReader = selectCmd.ExecuteReader()
                        autoreader.Read()
                        myrow = _DtText.NewRow()
                        myrow(mycol) = autoreader.GetValue(2)

Open in new window

0
Comment
Question by:isischen
  • 2
3 Comments
 
LVL 14

Expert Comment

by:raja_ind82
ID: 21748510
try this...

autoreader.fields(0).value

Regards,
M.Raja
0
 
LVL 14

Accepted Solution

by:
rachitkohli earned 1500 total points
ID: 21748715
myrow(mycol) = autoreader.Item("ColumnName")
0
 
LVL 14

Expert Comment

by:raja_ind82
ID: 21749024
rachitkohli  is correct.  sorry,  my answer is working only in VB.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question