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
284 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 39

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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 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: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

12 Experts available now in Live!

Get 1:1 Help Now