In any type of application (web/ desktop) which one is the best ?
1. making and closing the connection with database for each and every use.
2. make a connection and use that connection until the end of application.
3. whether, it depends upon the data source and/or application.?
Of course it will affect performance--opening and closing a connection takes time.
So, since your question was completely generic and provided zero useful information, the answer is "it depends". Sure sounds like an interview question to me, since you're not asking anything specific.