what I'am trying to do here is to select the connected people, but I don't really know how to do this. I have x names on the Listbox. I want to check for every name the login & logout times and if login is bigger then logout time, it types near the name "Connected", "not connected" on ListBox. Thank you in advance .
foreach (var Item in listBoxControl2.Items) { try { SqlConnection sqlConnection = new SqlConnection(ConnectDatabase); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "Select login_time_value,logout_time_value ConnectionTime.dbo.Avalaible where name = '" + Item.ToString() +"'"; sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (true) { bool flag = sqlDataReader.Read(); if (!flag) { break; } DateTime login = sqlDataReader.GetDateTime(0); DateTime logout = sqlDataReader.GetDateTime(1); if (login > logout) { } else { } } sqlDataReader.Close(); sqlConnection.Close(); } catch { } }