我想显示6个图片,数据库中不超过6条数据时可以正常显示,超过6条出现问题,(如7条,则最新第一个图片显示不出来),一下是代码
public void BindPic()
    {
        try
        {
            string sql1 = "select top 6 imgName,url from product_resident order by id desc";
            db.GetConnection();
            //SqlCommand cmd = new SqlCommand("select imgName,url from product_resident order by id desc ", con);
            //SqlCommand cmdNum = new SqlCommand("select count(ID) HAO from NewImage", con);
            string sql2 = "select count(id) HAO from product_resident";
            //SqlDataReader readNum = cmdNum.ExecuteReader();
            SqlDataReader readNum = db.GetDataReader(sql2);
            readNum.Read();
            int Number = (Convert.ToInt32(readNum.GetValue(0).ToString()));
            int changeNum = 0;
            if (Number >= 6)
            {
                changeNum = 6;
            }
            else
            {
                changeNum = Number;
            }            readNum.Close();
            SqlDataReader read = db.GetDataReader(sql1);
            string[] imgUrl = new string[6];
            //string[] imgtext = new string[6];
            string[] imgLink = new string[6];
            int count = 0;
            //string str = "";
            string pics = "";
            string links = "";
            //string texts = "";
            int focus_width = 165;
            int focus_height = 205;
            //int text_height = 18;
            int swf_height = focus_height;            while (read.Read())
            {
                imgUrl[count] = read.GetValue(0).ToString();
                //imgtext[count] = read.GetValue(1).ToString();
                imgLink[count] = read.GetValue(1).ToString();
                //str += imgUrl[count] + "escape(" + imgLink[count] + ")";
                if (count < (changeNum-1))
                {
                    pics += imgUrl[count] + "|";
                    links += imgLink[count] + "|";
                    //texts += imgtext[count] + "|";
                }
                if (count >= (changeNum - 1))
                {
                    pics += imgUrl[count];
                    links += imgLink[count];
                    //texts += imgtext[count];
                }
                count++;            }
            read.Close();
            //con.Close();
            if (Number != 0)
            //if (count != 0)
            {
                this.TD1.InnerHtml = "<script type='text/javascript'>" +
                "document.write('<object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 width=" + focus_width + " height=" + swf_height + ">');" +
                "document.write('<param name=allowScriptAccess value=sameDomain><param name=movie value=pixviewer.swf><param name=quality value=high><param name=bgcolor value=#F0F0F0>');" +
                "document.write('<param name=menu value=false><param name=wmode value=opaque>');" +
                "document.write('<param name=FlashVars value=pics=" + pics + "&links=" + links + "&borderwidth=" + focus_width + "&borderheight=" + focus_height + ">');" +
                "document.write('<embed src=pixviewer.swf wmode=opaque FlashVars=pics=" + pics + "&links=" + links + "&borderwidth=" + focus_width + "&borderheight=" + focus_height + " menu=false bgcolor=#F0F0F0 quality=high width=" + focus_width + " height=" + focus_height + " allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer />');  document.write('</object>');" +
                "</script>";
            }
            else
            {
                this.TD1.InnerHtml = "对不起本栏目暂时还没信息!";
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally
        {
            db.CloseConn();
        }    }
请高手帮忙