how i get limited latest 6 rows from table
<p>i am trying to retrieve latest 6 rows from my database table ,i am using max value but how 
i get limited 6 rows from table and that retrieved result to use in for loop,to display hyperlinks in panel
</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{

                String sql = "select title from up_song ";
                SqlDataAdapter adpt = new SqlDataAdapter(sql, cn);
                DataSet ds = new DataSet();
                adpt.Fill(ds, "title");
                if (ds.Tables["title"].Rows.Count &gt; 0)
                {
                    int m = ds.Tables["title"].Rows.IndexOf(ds.Tables["title"].Rows[8]);
                    int k = ds.Tables["title"].Rows.IndexOf(ds.Tables["title"].Rows[1]);

                    for (i=m; i &gt;= k ; --i)
                     {
                         try
                         {
                             hp[i] = new HyperLink();
                             hp[i].ID = "hp" + i;
                             hp[i].Text = ds.Tables["title"].Rows[i].ItemArray[0].ToString();
                             hp[i].NavigateUrl = "Downloadpage.aspx";
                             hp[i].ForeColor = System.Drawing.Color.White;
                             Panel1.Controls.Add(hp[i]);
                             Panel1.Controls.Add(new LiteralControl("&lt;br&gt;"));
                             HttpCookie coo = new HttpCookie("song");
                             coo["sogtit"] = ds.Tables["title"].Rows[i].ItemArray[0].ToString();
                             Response.Cookies.Add(coo);
                         }
                         catch(Exception ex)
                         {
                             Response.Write(ex.Message);
                         }
                    }
                }

                String sql1 = "select title from up_song where Song_type='Indian Pop Album'";
                SqlDataAdapter adpt1 = new SqlDataAdapter(sql1, cn);
                DataSet ds1 = new DataSet();
                adpt1.Fill(ds1, "title");


              if (ds1.Tables["title"].Rows.Count &gt; 0)
                {
                  String query = "select max(song_id) from up_song;";  
                  SqlDataAdapter adpt2= new SqlDataAdapter(query,cn);
                    DataSet ds2= new DataSet();
                  adpt2.Fill(ds2,"max");


                    //int m = ds.Tables["title"].Rows.IndexOf(ds1.Tables["title"].Rows[query]);
                    //int k = ds.Tables["title"].Rows.IndexOf(ds.Tables["title"].Rows[1]);

                    for (i = 0; i &lt;= ds2.Tables["max"].Rows.Count; ++i)
                    {
                        try
                        {
                            hp[i] = new HyperLink();
                            hp[i].ID = "hp" + i;
                            hp[i].Text = ds1.Tables["title"].Rows[i].ItemArray[0].ToString();
                            hp[i].NavigateUrl = "Downloadpage.aspx";
                            hp[i].ForeColor = System.Drawing.Color.White;
                            Panel2.Controls.Add(hp[i]);
                            Panel2.Controls.Add(new LiteralControl("&lt;br&gt;"));
                            HttpCookie coo = new HttpCookie("song");
                            coo["sogtit"] = ds.Tables["title"].Rows[i].ItemArray[0].ToString();
                            Response.Cookies.Add(coo);
                        }
                        catch (Exception ex)
                        {
                            Response.Write(ex.Message);
                        }
                    }

                }
              cn.Close();
</code></pre>
