SQLDataReader.GetValue Methods

Posted on 2006-04-06
Last Modified: 2010-10-05
If I have a query that returns 5 columns from the database
Select col1, col2, col3 from table
1) What method would I use from the SQLDataReader class.
This is the code snippet
 Dim sql_reader As SqlClient.SqlDataReader

 While (sql_reader.Read())
                        ' Return String Data
                  ---->      strBuilder = sql_reader.GetValue()
                             End While

I do not want to use  sql_reader.getInt32()..
I want to make it generic
Question by:eeiq
    1 Comment
    LVL 1

    Accepted Solution

    suppose sdr is SQLDataReader.
    you can use sdr.Item(0) to get the first column, sdr.Item(1) to get the second column, etc.
    or sdr.Item("col1") where you can give the column name you want to read

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    I previously wrote an article addressing the use of UBCD4WIN and SARDU. All are great, but I have always been an advocate of SARDU. Recently it was suggested that I go back and take a look at Easy2Boot in comparison.
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
    This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.

    734 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

    25 Experts available now in Live!

    Get 1:1 Help Now