William Vaughn
8/17/2007 7:16:00 PM
Depending on the data source, getting a connection can take some time,
however, in my experience, acquiring a SQL Server connection (after the
first) takes less than a second--whether or not you're pooling.
And no, I don't agree that connection pooling makes sense or is at all
necessary for Windows Forms applications. I agree that it's essential for
ASP-based applications or XML Web Services, but not for Windows Forms. I
recommend opening the Connection and leaving it open for the life of the
application. Does this reduce scalability? Sure, to about 3000
connections--far more than any MSDE engine could handle.
I doubt if it's connection overhead that's causing the problem, but it would
be easy to tell. Set the ConnectionTimeout to a low value (say, 10 seconds)
and trap the error/exception. If it goes off you have something to debug.
Consider that SQL Server does not pre-allocate space in the database. From
time to time as new rows are added, it must go off an build extents and
expand the database. On a wimpy system or one that's being used for other
operations (where SQL Server must share resources with other processes),
this can take 10-30 seconds. To prevent the user from clicking and
restarting, be sure to "entertain" them with a progress bar--and make sure
to disable the mouse or the ability to click again in the form. However,
I've found that if the user sees an hourglass, a progress-bar or some other
indication that the app is running they won't reboot. Of course in some
cultures, the propensity to reboot is far shorter (as in New York) or far
longer (as in Arkansas) so your success-rate may vary.
I discuss these approaches in detail in my book.
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"Timbo" <me@home.com> wrote in message
news:%236IXdlO4HHA.5724@TK2MSFTNGP05.phx.gbl...
>I think I may have the answer.
>
> After reading about connection pooling, I think I might have my answer....
> Am I right in saying.....
>
> At the moment my application opens a OLEDB connection when the user starts
> the application. At no point is the connection closed until the
> application quits (even then I don't think I have a close command),
> however I ALWAYS close and release recordsets and commands. If I was to
> close the connection every time I retrieved a recordset or executed a
> command (or whatever), because of connection pooling the performance
> wouldn't be hit, but each command will have a nice new fresh connection to
> use.
>
> What do you reckon?
>
>
> "Dave Michaud" <DaveMichaud@discussions.microsoft.com> wrote in message
> news:4E6D21D8-087E-4894-98D8-460F6ABAA58F@microsoft.com...
>> Lots of possibilities here - Missing index, insufficient RAM on DB or
>> Client,
>> Network storm. What's the app doing during the hang? Use Profiler to see
>> what the DB is doing. Does 2005 SP1 or SP2 work any better?
>>
>> "Timbo" wrote:
>>
>>> I have a fairly heavy duty app that can use SQL2005, however I am
>>> getting
>>> some rather strange behaviour, if MSDE or SQL2000 is used, this doesn't
>>> appear to happen. Here's what happens:
>>>
>>> The VB6 application makes fairly regular calls on the database (only
>>> when
>>> the user requests data). At what appears to be completely random times
>>> (when the user makes a request for data) the application will lock up
>>> for
>>> anything up to 1 minute before carrying on. Obviously the user thinks
>>> the
>>> machine has crashed and starts clicking everywhere, which does make the
>>> application crash!
>>>
>>> This does not appear to happen with MSDE or SQL2000 databases. My
>>> application opens and maintains only one connection to the database,
>>> where
>>> all the SQL requests are piped through. I'm wondering if this is good
>>> practice? Also my application never maintains open recordsets, I always
>>> use
>>> SELECT to populate a screen, and only when the user hits a save button
>>> does
>>> the database get updated with UPDATE and INSERT SQL commands.
>>>
>>> If no one can shed any light on this specific problem, does anyone have
>>> a
>>> guide for best practices when it comes to connection states.
>>>
>>> Kind Regards
>>>
>>> Tim
>>>
>>>
>>>
>
>