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
289 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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