Is it normally to create an instance "connection" (type of MySqlConnection) every time in every methods in form (I have about 20 methods) and open connection with Open method (in the start of the method) and close connection with Close method (in the end of the method)?
Code (one of my methods):
private void buttonOk_Click(object sender, EventArgs e)
{
MySqlConnection conn = new MySqlConnection(connStr);
conn.Open();
// other code
conn.Close();
}
Or in my case it is better to create a field inside form class and open connection in constructor and close connection in the form_closed method or in destructor?