It is necessary on request from the textbox to display a table from MySql. I assume a conclusion in DataGrid, but I do not understand how to implement it.
The datagrid accepts a typed collection. However, it is not possible to create a class for the table object, since adding new fields is not excluded.
That could squeeze out:
string connstr = "server=localhost; user=root; database=lab_3; password=0000"; using (MySqlConnection conn = new MySqlConnection(connstr)) { conn.Open(); string query = "SELECT * FROM new_table;"; MySqlCommand command = new MySqlCommand(query, conn); MySqlDataReader reader = command.ExecuteReader(); ArrayList arrayList = new ArrayList(); if (reader.HasRows) { while (reader.Read()) { int index = 0; arrayList.Add(reader[index]); } grid.ItemsSource = arrayList; reader.Close(); } I will be glad to any suggestions and ideas!