i'm picking up datas from a mysqldatabase and throwing in variables in a C# application. I'm using this code :
int forcatime;
string comandomedia = "select avg(forca_jogador) from jogadores where nome_time = " + time;
ocon.ConnectionString = con;
MySqlCommand media = new MySqlCommand(comandomedia, ocon);
ocon.Open();
forcatime = Convert.ToInt32(media.ExecuteScalar());
ocon.Close();
After doing this I convert "forcatime" ToString and throw it in a MessageBox.
I'd like to know if there's a way to create a class for this operation because everytime I have to do it I write all the code again and again. Thanks