>In my framework, when responding to a Web site, the connection is created at every hit. I never executed the Close() method of the connection object because it has always been my assumption that this was going out of scope once the hit is done. But, I just found this was not the case. This was why the VFPOleDb data provider, when accessing VFP data, was making it impossible for an administrator to use a table in exclusive mode. As soon as I added a call to the Close() method in my EndRequest() method, this has resolved the issue.
>
>I am curious to know more about this. Are there any other reasons to close the connection once the hit is processed?
You should always close a connection as soon as possible (and open it as late as possible). The simplest way to achieve this is probably to wrap it in a using{} block. If you have connection pooling enabled (the default) it shouldn't affect performance.
If you're *not* closing connections it could account for the performance issues you were experiencing - they'll be hanging around until the GC gets to them. Did you monitor the number of open connections?
Regards,
Viv
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only