Well there are two ways to loop through the data(s). Whether you want to loop through connected or through the disconnected way. If I'm not mistaken the above answers by our members are disconnected way(correct me if wrong).
Below example is the way to loop through the database while connected:
try
{
conn.Open();
string commString = "SELECT * FROM database_table";
SqlCommand comm = new SqlCommand(commString, conn);
SqlDataReader reader = null;
reader = comm.ExecuteReader();
while (reader.Read())
{
if (reader["myID"].ToString() == textSearch.Text)
{
textID.Text = reader["myID"].ToString();
textName.Text = reader["myName"].ToString();
textIC.Text = reader["myIC"].ToString();
textAddress.Text = reader["myAddress"].ToString();
textContact.Text = reader["myContact"].ToString();
}
}
}
finally
{
conn.Close();
}
myID,myName... are the columns for each row in the table