Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code for Read and Display of date:
C#
if (dr.Read())
       {
           if (dt.Rows.Count > 0)
           {
               //for (int i = 0; i < 10; i++)
               //{
                  str1 += dr[0].ToString()+"'";
                  str2 = dr[1].ToString()+"'";

               //}
           }
       }

I want to display all rows and column datas.But it display only first row.

Please help me how to solve this.

Thanks in Advance.
Posted
Updated 18-May-11 3:21am
v2

Instead of using if (dr.Read()) use while (dr.Read())!
 
Share this answer
 
Use liek that
while (dr.Read())
{
          //for (int i = 0; i < 10; i++)
               //{
                  str1 += dr[0].ToString()+"'";
                  str2 = dr[1].ToString()+"'";
 
               //}
}
 
Share this answer
 
Use
while (dr.Read()). 
Hope it will solve your problem.
 
Share this answer
 
if(dr.read())
{
textbox.text=dr[0].tostring();
textbox1.text=dr[1].tostring();
.....
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900