I have my own database, which I manage in phpmyadmin. I write down the data in this form (see code). How do I connect a db to my dataGridView? So that after pressing a key, all my DB would be transferred to the dataGridView.
private void insertData() { string conStr = "server=127.0.0.1;user=user;" + "database=newBase;password=12345"; using (MySqlConnection con = new MySqlConnection(conStr)) { try { string a = File.ReadAllText(@"title.txt", Encoding.Default); string b = File.ReadAllText(@"text_out.txt", Encoding.Default); string sql = "INSERT INTO items (Name, Cost) VALUES (@a, @b)"; MySqlCommand cmd = new MySqlCommand(sql, con); cmd.Parameters.AddWithValue("@a", a); cmd.Parameters.AddWithValue("@b", b); con.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }