Jason Gates wrote:
> Dear all
>
> I have written a very complex web app for intranet use. It allows
> users to search a large database and then returns formatted results. I
> am currently employing a method as below:
>
> 1. Create a global database connection
Ignore the following if you mean that you are opening a database connection
on each page.
************************************************** ********
Assuming you are storing this connection in Application, this is very bad.
ADO objects are not free-threaded, which means only one thread will be able
to use this connection object at a time. Connections should be opened late
and closed early in each page in which they are used.
http://www.aspfaq.com/2053
It is possible to use a batch file called makfre15.bat (located in
C:\Program Files\Common Files\System\ADO on my machine) to cause a registry
change to make the ADO objects free-threaded, allowing you to use them in
Application. However, if any applications on that machine are connecting to
Jet databases (Access), YOU MUST NOT DO THIS.
************************************************** ********
> 2. Open a recordset that searches the database
> 3. Loop through recordset calling the relevant function from an
> include file to display results
> 4. Loop until EOF or PageSize reached.
Here are some alternatives that may improve your performance:
http://www.aspfaq.com/show.asp?id=2120
> 5. Close and destroy recordset
> 6. Close and destroy connection
Excellent.
You may wish to consider using GetRows arrays to avoid all the recordset
looping - looping through recordsets is incredibly slow compared to looping
through arrays. Better yet, if possible, make use of GetString. Take a look
at this:
http://www.aspfaq.com/show.asp?id=2467
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"