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.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Oct 20, 2011, 1:11 PM
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 NairPosted Oct 20, 2011, 1:14 PM