Last post Jan 11, 2018 12:21 PM by TW88
Jan 11, 2018 08:44 AM|TW88|LINK
is it ok to put it on top of code page and share the sql connection for all subs?
Shared SQLCS As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ABCConnectionString").ConnectionString)
it seems not good to type it again and again in a same code page.
Any use if different sql connection names are defined for different Subs? Just for clarification?
Thanks a lot for your advice.
Jan 11, 2018 09:48 AM|PatriceSc|LINK
Don't use Shared. for this. You would then use a single connection for ALL users. As usual you can place repetitive code in your own class/methods to build a thin data access layer.
I don't see which benefit would bring using another connection name depending on the sub ? Seems it would be just more complex than clearer. Do things if you see a real benefit.
For example if you have an architecture with a read/write db and read only replicas you could have a read/write connection and a read/only connection to spread load (and if read needs are significant compared with read/write needs)
Jan 11, 2018 12:21 PM|TW88|LINK
Thanks a lot for your clear explanation.