0

i want to retrieve 2nd row of a column from datareader object...

i want to show 1st row value of datareader..... if seattype_code == "00", 2nd row value if seattype_code == "01"...and so on.....

what method shud i use for dr..as it is not working that i tried..?

dr = cmd.ExecuteReader();
                        if (dr.HasRows)
                        {
                            if(dr.Read())
                            {

                                if(seattype_code == "00")
                                {
                                    lblSeatType.Text = dr.GetString(0).ToString();
                                }
                                else 
                                    if (seattype_code == "01")
                                {
                                    lblSeatType.Text = dr.GetInt32(1).ToString();
                                }
                                else if (seattype_code == "02")
                                {
                                    lblSeatType.Text = dr.GetInt32(2).ToString();
                                }
                                else if (seattype_code == "03")
                                {
                                    lblSeatType.Text = dr.GetChars.GetString(3).ToString();
                                }

thnx in advance..

Edited by Reverend Jim: Fixed formatting

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by __avd
0

You can not. Data reader works with current row only. You can, however, buffer read data, or use data table.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.