0
string sid = Session["id"].ToString();
            string q1, q2;
            q1 = "select count (*) from All_msg where target_id = '" + sid + "'";
            SqlCommand cmd1 = new SqlCommand(q1, cn);
            int v1;
            v1 = (int)cmd1.ExecuteScalar();

            q2 = "select count (*) from All_msg where target_id = '" + sid + "'";
            SqlCommand cmd2 = new SqlCommand(q2, cn);
            SqlDataReader rdr1 = cmd2.ExecuteReader();
            while (rdr1.Read())
            {
                if (rdr1.HasRows)
                {
                    TableRow tr1 = new TableRow();
                    TableCell t1 = new TableCell();
                    string s1 =  Convert.ToString(rdr1["id"]);
                    t1.Text = s1 ;
                    tr1.Cells.Add(t1);

What Should I do?

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

I found new error like : Index was outside the bounds of the array.

TableCell t2 = new TableCell();
                    s1 = rdr1[5].ToString();
                    t2.Text = s1;
                    tr1.Cells.Add(t2);

                    TableCell t3 = new TableCell();
                    t3.Text = rdr1[1].ToString();
                    tr1.Cells.Add(t3);

                    TableCell t4 = new TableCell();
                    t4.Text = (string)rdr1[2].ToString();
                    tr1.Cells.Add(t4);
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.