By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,708 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

Viewing the NEXT RECORD using DATA READER

P: n/a
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.NextRecord() , it is
possible. Is the following code correct?

My code ::
System.Data.SqlClient.SqlDataReader d1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

}

private void Button1_Click(object sender, System.EventArgs e)
{

sqlCommand1.Parameters["@a"].Value=txtC.Text;
sqlConnection1.Open();
d1= sqlCommand1.ExecuteReader();
do
{

while(d1.Read())
{
TextBox3.Text= d1["Company"].ToString();
TextBox4.Text=d1["Ceo"].ToString();
TextBox5.Text=d1["Month"].ToString();
}
}while(d1.NextResult());
d1.Close();
sqlConnection1.Close();
}
--
pmud
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.