Computer Learning Zone CLZ Access Excel Word Windows

Remember to look up at the stars and not down at your feet.

-Stephen Hawking
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
OK, I fixed it
By Richard Rost   Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   10 years ago

I was finally able to recreate the problem that has been plaguing a few users for a while now. When you sign up for emails to tell you that the Forums or News Feed (what you're reading now) have been updated, you get a link to click on to come directly here (or to the Forum in question). That link could sometimes freeze and take MINUTES to load, and even then display gibberish.

Well, I finally figured out what the problem is. It was a programming conflict caused by yours truly which involves laziness, shortcuts, and having web site code that's been copied, pasted, and crossed like lights on a Christmas tree.

For those of you who don't care about programming, rest assured the problem has been fixed.

For the rest of you, here's a teaching moment...

I have a global function called MakeLogEntry() which is #included in the ASP of just about every page on my site. It allows me to create my own database log files. The IIS text logs are inadequate so I made my own. In any case, this function works great 99.999% of the time.

However... since I've recently been moving things around, changing code on the fly, yadda yadda yadda... a problem came up where I ended up accidentally having multiple conflicting recordsets loading on the same page. This would ONLY happen if the new user logon code tried to pull up your user record AT THE SAME TIME as trying to save your automatic login attempt to the log file.

Oops. This caused an endless loop and a gibberish recordset to try and display garbage until the script timed out... at about 2 minutes.

Once I discovered the problem it was an easy fix. HOWEVER, this problem wouldn't happened in the first place if I had just not been lazy and properly DIMmed my variables in my functions. See the function looks kind like this:

Function MakeLogEntry(SomeStuff)
set conn = ... database connection
set rs = ... recordset
record the data
set rs = nothing
set conn = nothing
End Function

OK, that's all fine and dandy, but if you don't DIM your variables INSIDE the function, ASP/VB assumes that if the variable already exists on the page that you want to use THAT variable. So when my function code is #included inside another page, if there's already a CONN or RS variable (which there was in this case) it uses those... then destroys those (=Nothing) and that caused the problem.

All I had to do was add one line of code to fix the problem:

Dim Conn, rs

And now those are LOCAL variables inside the function. The other recordsets on the page don't have a cow, and all is well with the world. See... being a lazy programmer WILL come back to bite you in the ass.

Thanks to Chris, Willem, Phillip, Alex, and everyone else who helped me to nail down this problem! You guys are the best.

Comments for OK, I fixed it
Age Subject From
10 yearsOK I fixed itKevin Robertson
10 yearsOK I fixed itJames F
10 yearsOK I fixed itRichard R


Start a NEW Conversation
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
PermaLink  OK, I fixed it