Hi,
In my window application, record is displayed in TextBox. I have a next Button on the form. I want to show next record in TextBox on Next Button Click(event). What will be code for it. plz, help me.
Thanks.
How to show next record
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 20, 2011, 9:11 AM EDT
Try this.........
using System.Data.SqlClient;
public class Form1 : System.Windows.Forms.Form
{
SqlConnection con=new SqlConnection("server=localhost;uid=sa;pwd=;database=pintu");
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds=new DataSet();
String str;
BindingManagerBase bm;
private void btnload1_Click(object sender, System.EventArgs e)
{
con.Open();
str = "select * from student";
com = new SqlCommand(str,con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "student");
txtid.DataBindings.Add("Text", ds, "student.sid");
txtname.DataBindings.Add("Text", ds, "student.sname");
txtmarks.DataBindings.Add("Text", ds, "student.smarks");
txtaddress.DataBindings.Add("Text", ds, "student.saddress");
txtyear.DataBindings.Add("Text", ds, "student.year");
bm=this.BindingContext[ds,"student"];
bm.Position = 0;
con.Close();
}
private void btnnext_Click(object sender, System.EventArgs e)
{
bm.Position += 1;
}
}
Thanks
Suthish NairRank #92 · 22.8K reputationPosted Oct 20, 2011, 9:14 AM EDT