public void FillListAdmin() { try { string UserNameForChecking = HttpContext.Current.User.Identity.Name; /* For checking admin permission. */ conn = new SqlConnection("server=10.100.100.25\\SPLAHOST;Database=graphs;Integrated Security=false;User ID=petpakn;Password=net123321!;"); conn.Open(); // Create SqlCommand to select pwd field from users table given supplied userName. cmd = new SqlCommand("Select uname from Users", conn); /// Intepolation or the F string. C# > 5.0 // Execute command and fetch pwd field into lookupPassword string. SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { admins.Add(sdr["uname"].ToString()); } listAdmin.DataSource = admins; listAdmin.DataBind(); ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings; conn = new SqlConnection("server=10.100.100.25\\SPLAHOST;Database=graphs;Integrated Security=false;User ID=petpakn;Password=net123321!;"); conn.Open(); // Create SqlCommand to select pwd field from users table given supplied userName. cmd = new SqlCommand("select company_name from companies ", conn); /// Intepolation or the F string. C# > 5.0 // Execute command and fetch pwd field into lookupPassword string. SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { strings.Add(reader["company_name"].ToString()); } ConnectionStrings.DataSource = strings; ConnectionStrings.DataBind(); // unit test cmd.Dispose(); conn.Close(); } catch (Exception ex) { // Implement logging here. } }