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

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

To fetch data from next row, you can do this by invoking dr.Read() method again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.