Q:

Do is recommended to create a class to open/close a connection and execute commands in a database?

My professor of C# at a course I'm taking, told us to use a class that he wrote that open/close a connection and execute commands in a database (SQL Server and MySQL). Do is recommended to use this type of classes while developing a program, do experienced developers use this things? 

A:

Is this recommended to use this type of classes while developing a program?

Yes, this kind of classes can save you a bunch of headaches in later development of program.Secondly, all database related logic comes in a single class for reusability. Also, if you make any changes to this class , then they will apply to whole program.

Do experienced developers use this things?

Yes, programmers generally separate the data access layer, in a separate class or a class library depending upon the size of the project.
But, developers are not limited to only this kind of classes, they leverage the use of ORMs for saving them time.ORM often reduces the amount of code that needs to be written. ORMs can automate much of the CRUD from the application. Stored procedures are good for adding abstraction, adding a layer of security and optimizing area’s that need to be highly performant.Some ORMs can be listed as below:

Entity Framework
SubSonic
NHibernate
Dapper
OrmLite
PetaPoco etc

