Viewing the NEXT RECORD using DATA READER

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pmud

    Viewing the NEXT RECORD using DATA READER

    I have an application (ASP.Net using C# ) . I need to read records from the
    database based on the value entered by the user. Using Data Reader , I can
    see only one record in text boxes. But how do i view the next record in the
    text boxes?? I found out that using DataReader.Next Record() , it is
    possible. Is the following code correct?

    My code ::
    System.Data.Sql Client.SqlDataR eader d1;

    private void Page_Load(objec t sender, System.EventArg s e)
    {
    // Put user code to initialize the page here

    }

    private void Button1_Click(o bject sender, System.EventArg s e)
    {

    sqlCommand1.Par ameters["@a"].Value=txtC.Tex t;
    sqlConnection1. Open();
    d1= sqlCommand1.Exe cuteReader();
    do
    {

    while(d1.Read() )
    {
    TextBox3.Text= d1["Company"].ToString();
    TextBox4.Text=d 1["Ceo"].ToString();
    TextBox5.Text=d 1["Month"].ToString();
    }
    }while(d1.NextR esult());
    d1.Close();
    sqlConnection1. Close();
    }


    --
    pmud
Working...