|
-
Jan 20th, 2006, 08:20 PM
#1
One public connection or not?
What's the recommended way in .Net? Or create one as you need it?
-
Jan 20th, 2006, 08:32 PM
#2
Re: One public connection or not?
There would be arguments either way but I'd go with the single connection.
-
Jan 20th, 2006, 08:38 PM
#3
Re: One public connection or not?
One connection but open and close it as necessary.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 20th, 2006, 09:30 PM
#4
Re: One public connection or not?
I have the same faith as you both but digging into some samples out there it seems they are creating a connection object each time hence I wish to be enlightened...
-
Jan 20th, 2006, 09:48 PM
#5
Re: One public connection or not?
It depends how far you want to take encapsulation and code reuse. Even if you create multiple connections you need to have a common connection string. To code a different connection string for each connection goes against the grain because then a change would need to be replicated in multiple locations. It depends whether you want each form/object to have its own connection and each of those connections to get their connection string from a common location, or you want each form/object to use a common connection. Like I said, there would be valid arguments on either side.
-
Jan 23rd, 2006, 02:47 AM
#6
Re: One public connection or not?
This one is against our faith, what can you say about it?
-
Jan 23rd, 2006, 03:27 AM
#7
Re: One public connection or not?
I'm guessing that that guy knows more about ADO.NET than I do. I have heard of connection pooling but I have to admit that I don't know the details. From a quick glance it would appear that behind the scenes, two connection objects with the same connection string will be pooled into a single connection. You would still have to create multiple instances of the connection class, but that is quite possibly offset by other factors. From what he says it sounds like there are several valid reasons to use multiple connection objects, but the subject does warrant further investigation.
-
Jan 23rd, 2006, 03:34 AM
#8
Re: One public connection or not?
That brought me to dilemma, I hope our database experts would see this thread, paging szlamany, techgnome, mendhak and the others!!!
-
Jan 23rd, 2006, 04:54 AM
#9
Re: One public connection or not?
My answer would be, it depends upon the architecture of your application. You cannot decide the architecture based upon what you want or feel is the best way to do something that is merely a fraction of the overall architecture.
Example: If you have a web application wherein each page will be making multiple calls, and this of course will be accessed by several people per second, then it makes sense to use an instance of a connection rather than relying upon connection pooling.
In an other scenario, like with winforms applications where you have a single user on a single machine, there isn't much of a need for the instance.
-
Jan 23rd, 2006, 07:49 AM
#10
Re: One public connection or not?
-
Jan 24th, 2006, 08:10 AM
#11
Re: One public connection or not?
dee-u...
I made another post in the thread in the DB section...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|