Answer the question
In order to leave comments, you need to log in
How to make a filter output from the data table?
Good afternoon everyone! I have a form (Fig. 1) which displays data from a table. How can I make it so that if the data is repeated, then they are displayed only once?
(Fig. 1)
The figure shows that the names of the topic and subject are repeated (punctuation and Russian).
private void allTests()
{
string connStr = "server=localhost; port=3306; username=root; password= root; database=vedar_bd";
string sql = "SELECT subject_name, subject_title FROM subjects ";
MySqlConnection conn = new MySqlConnection(connStr);
conn.Open();
MySqlCommand command = new MySqlCommand(sql, conn);
MySqlDataReader SomeTest;
DataTable tableTest = new DataTable();
SomeTest = command.ExecuteReader();
tableTest.Load(SomeTest);
ListItem1[] listitems = new ListItem1[SubjNumber];
for (int i = 0; i < SubjNumber; i++)
{
listitems[i] = new ListItem1();
listitems[i].Subject = tableTest.Rows[i][0].ToString();
listitems[i].Title = tableTest.Rows[i][1].ToString();
if (flowLayoutPanel1.Controls.Count < 0)
{
flowLayoutPanel1.Controls.Clear();
}
else
flowLayoutPanel1.Controls.Add(listitems[i]);
}
conn.Close();
}
private void LastNumber()
{
string connStr = "server=localhost; port=3306; username=root; password= root; database=vedar_bd";
string sql = "SELECT COUNT(*) FROM subjects";
MySqlConnection conn = new MySqlConnection(connStr);
conn.Open();
MySqlCommand command = new MySqlCommand(sql, conn);
string number = command.ExecuteScalar().ToString();
int xnumber = int.Parse(number);
SubjNumber = xnumber;
conn.Close();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question