Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have developed a windows base application in WPF with VB Script, database is SQL Server 2012 and crystal report I have open a sql connection while starting my application and using this connection string this way Dim sqlconn As SqlConnection = Application.Current.Properties("sqlcn") in entire application in. This connection close only when application will close.
What should I do?
when I create new instance of every form with new connection
or
My correct logic is best
Posted
Updated 29-Dec-15 23:05pm
v2

1 solution

You should open a connection only when you want to access the database, and close it as soon as you receive the results.
 
Share this answer
 
Comments
Member 10497060 30-Dec-15 5:14am    
What is the benefit of open and close connection when going to sql transaction? and
what is the drawback or problem of my practice?
Richard MacCutchan 30-Dec-15 5:20am    
You should not hold open connections to a database, as it consumes resources.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900