|
-
Jul 22nd, 2004, 08:31 PM
#1
Thread Starter
Frenzied Member
Is this bad? sqlConnection and command [RESOLVED]
I declared a public SqlConnection and SqlCommand in a module and made it public. I re-use those throughout the life of the app and simply open and close as necessary the connection object and change the command.commandText property as needed. Is that better or worse or the same as going through that process time and time again for each function/sub that may need it?
Last edited by Andy; Aug 13th, 2004 at 11:55 AM.
-
Jul 22nd, 2004, 08:35 PM
#2
I wonder how many charact
Perfectly fine...
just make sure you check the connection's state property often..
VB Code:
If SqlConnection1.State = ConnectionState.Open Then SqlConnection1.Close
-
Jul 22nd, 2004, 08:48 PM
#3
Thread Starter
Frenzied Member
good to know that. i have a routine that checks exactly that and closes it if open. I was worried that my way would not utilize connection pooling correctly and eventually my app would bottleneck.
-
Jul 22nd, 2004, 09:21 PM
#4
PowerPoster
Just use the data application block from MS, then you don't need to do that...
http://msdn.microsoft.com/library/de...ml/daab-rm.asp
-
Jul 23rd, 2004, 12:18 AM
#5
I can personally vouch for the benefits of the DAABs. Intuitive, easy to use, and efficient. And its basically the same thing you're doing in a very generalized fashion.
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
|