Solved

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

Posted on 2008-06-09
3
152 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 500 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now