Hello!
Help please, I am new to programming. Here, I can’t understand one thing: when typing a name into a user several times on a textBox dataGridView should output not several times lines but the number of names that were entered on the same line. The code does not work. And how to do it. Thank you very much in advance!
List<User> usn = new List<User>(); conn.Open(); SqlCommand seldb = new SqlCommand("Select * from User where username="+textBox1.text, conn); seldb.ExecuteNonQuery(); SqlDataReader read = seldb.ExecuteReader(); int i=0; int j = 0; while (read.Read() == true) { User ia = new User(); ia.Name = read["name"].ToString(); usn.Add(ia); if (dataGridView1.Rows[j].Cells[1].Value.ToString().Contains(textBox1.Text)) { ia.Count = i; } i++; } conn.Close(); dataGridView1.DataSource = usn;
Select *you get all the information about the contents, trySelect Count(*)- Pyrejkee