asp.net c# using next button to display successive query results text fields

nksrpibkam

New Member
I am trying to query database and display successive results on text fields. the code i have shows the current record and the next; it does not go beyond two query results: \[code\]protected void next_Click(object sender, EventArgs e) { try { string conStr = ConfigurationManager.ConnectionStrings["MyServer"].ConnectionString; SqlCommand cmd = null; using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(conStr)) { cmd = new SqlCommand("SELECT * FROM Members WHERE Name like'%" + searchBox.Text + "%'", con); con.Open(); //SqlDataReader dr = cmd.ExecuteReader(); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); if (i < ds.Tables[0].Rows.Count-1) { ++i; MemberNumber.Text = ds.Tables[0].Rows["Member_No"].ToString(); MemberName.Text = ds.Tables[0].Rows["Name"].ToString(); IdNumber.Text = ds.Tables[0].Rows["ID_NO"].ToString(); DateTime joined = Convert.ToDateTime(ds.Tables[0].Rows["Date_Applied"]); DateApplied.Text = joined.ToShortDateString(); object ob = ds.Tables[0].Rows["Date_Left"]; string s = ob.ToString(); if (s != "") { DateTime left = Convert.ToDateTime(ds.Tables[0].Rows["Date_Left"]); DateLeft.Text = left.ToShortDateString(); } else { DateLeft.Text = ds.Tables[0].Rows["Date_Left"].ToString(); } if (DateLeft.Text == "") { StatusBox.Text = "Active"; } else { StatusBox.Text = "Inactive"; } DateTime prepared = Convert.ToDateTime(ds.Tables[0].Rows["DatePrePared"]); DatePrepared.Text = prepared.ToShortDateString(); PreparedBy.Text = ds.Tables[0].Rows["PreparedBy"].ToString(); MemberImage.ImageUrl = "http://localhost:56394/CallMarkSite/Pages/Handler3.ashx?id=" + ds.Tables[0].Rows["Name"]; } else { }\[/code\]
 
Back
Top