Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how can i get second column in first row of a data reader. This is the only value I need

Posted on 2014-07-31
1
291 Views
Last Modified: 2014-07-31
how can i get second column in first row of a data reader. This is the only value I need
0
Comment
Question by:Angela4eva
1 Comment
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40231793
Assuming you know how to execute a command:


Dim dr as SqlDataReader = cmd.ExecuteReader()
Dim value as String

if dr.HasRows then
       dr.Read()
       value = dr("NameOfSEcondColumn)
else
    value = "No Rows!"
end if


Note that you could also change the select statement to retrieve just the one value . . . then the code would be:

Dim value as string = cmd.ExecuteScalar()
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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 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