Here is an example; put your code inside that conn.open() and conn.close().
Hope it works.
conn.Open();
SqlCommand cmd = new SqlCommand(@"select _regno from _registration", conn);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
dt = new DataTable();
ada.Fill(dt);
conn.Close();