try something like this….
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand com = new SqlCommand("SELECT FirstName, LastName, EmailId, MobileNUmber FROM myTable WHERE id=@ID", con))
{
com.Parameters.AddWithValue("@ID", iD);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(com);
da.Fill(dt);
txtFirstName.Text = dt.Rows[0]["FirstName"];
txtName.Text = dt.Rows[0]["LastName"];
}
}
3
solved Display table values in textboxes [closed]