DataSet st = new DataSet(); string strConnectionString = "Data Source=JAMES-PC\\SQLEXPRESS;Initial Catalog=staff;Integrated Security=True"; SqlConnection objconnection = new SqlConnection(strConnectionString); using (SqlCommand cmd = new SqlCommand("SELECT [name] FROM [staff1]", objconnection)) { using (SqlDataAdapter adapter = new SqlDataAdapter(cmd)) { adapter.Fill(st); } } var empList = st.Tables[0].AsEnumerable().Select(dataRow => dataRow.Field<string>("name")).ToList(); listBox1.DataSource = empList; listBox1.SelectedIndex = 0; listBox1.Refresh(); tried listBox1.Refresh(); almost everywhere , didnt help, also tried public void RefreshItem2(int index) { RefreshItem(index); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)