Question

ASP and SQL problem with sessions - Lose server temporarily.

Asked by: HypercubeTech

We have a site w/shopping cart on Verizon's MySuperpages.com (don't ask). It was on Verizon (there's a difference appearently).

I didn't write it but I gotta fix it. On the new server when you go to the main page, index.asp, sometimes it doesn't come up and sometimes it does. Don't know if has anything to do with people using the cart or not.. I don't imagine there are more than 2 or 3 (if any) people on at any one time.  Code below:

index.asp basically says

include   SQL.asp   at the very top (which is also on all of the other pages)
include   links.asp
some html bs

and the SQL.asp is as follows, i think this is where the prob is.

SQL.asp (please remember i didn't write this, but could this asp be locking up the server intermittantly?)

<%

connectionInfo = "Provider=SQLOLEDB;UID=XXXXXX;PWD=XXXXX;Data Source=XX.XXX.XXX.XXX;"
'connectioninfo = "Provider=SQLOLEDB;UID=Matt;PWD=XXXXXX;Data Source=dsorce;Initial Catalog=WEBDB"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString=connectionInfo
Conn.Open

If session("ID") = "" Then
'*******************************************************      
'This sections returns the new Session ID

      cmdText = "Select * From primary_key"
      set rs = server.CreateObject("ADODB.recordset")
      rs.open cmdText, conn
      session("ID") = rs("sessions")      
      set rs = nothing
'******************************************************
'This section updates the new ID in the primary key table

      cmdText = "Select * From primary_key "
      set rs = server.CreateObject("ADODB.recordset")
      With rs
            .ActiveConnection = conn
          .CursorType = 2 'adOpenDynamic
          .LockType = 3 'adLockOptimistic
            .Open cmdText
      End With
      rs("sessions") = session("ID") + 1
      rs.update
      set rs = nothing      
'**********************************************************
'This is where the timestamp and ID gets set in the temp_IDs

      cmdText = "Select * From temp_IDs"
      set rs = server.CreateObject("ADODB.recordset")
      With rs
            .ActiveConnection = conn
          .CursorType = 2 'adOpenDynamic
          .LockType = 3 'adLockOptimistic
            .Open cmdText
      End With
      rs.addnew
      rs("ID") = session("ID")
      rs("timestamp") = Date
      rs.update
      set rs = nothing      
'********************************************************
'Here I check to see if the session number is more than
'1 day old and if it is I will delete it from the DB.

      cmdText = "Select * From temp_IDs"
      set rs = server.CreateObject("ADODB.recordset")
      rs.open cmdText, conn
      
      Do While not rs.eof
            strDateDiff = DateDiff("d",rs("timestamp"),Date)
            If strDateDiff > 1 Then
                  cmdText = "Delete From orders Where SessionID = " & rs("ID")
                  set rsDelete = server.CreateObject("ADODB.recordset")
                  rsDelete.open cmdText, conn
                  set rsDelete = nothing

                  cmdText = "Delete From addresses Where ID = " & rs("ID")
                  set rsDelete = server.CreateObject("ADODB.recordset")
                  rsDelete.open cmdText, conn
                  set rsDelete = nothing

                  cmdText = "Delete From payment Where ID = " & rs("ID")
                  set rsDelete = server.CreateObject("ADODB.recordset")
                  rsDelete.open cmdText, conn
                  set rsDelete = nothing
                  
                  cmdText = "Delete From userinfo Where ID = " & rs("ID")
                  set rsDelete = server.CreateObject("ADODB.recordset")
                  rsDelete.open cmdText, conn
                  set rsDelete = nothing

                  cmdText = "Delete From temp_IDs Where ID = " & rs("ID")
                  set rsDelete = server.CreateObject("ADODB.recordset")
                  rsDelete.open cmdText, conn
                  set rsDelete = nothing
            End If
            rs.movenext
      Loop
      set rs = nothing


      session("REFER") = request.servervariables("HTTP_REFERER")
      session("ADDR") = request.servervariables("REMOTE_ADDR")      
      Session.Timeout = 120
      
'      cmdText = ""
'      set rs = server.CreateObject("ADODB.recordset")
'      rs.open cmdText, conn
      
      
      
End If
%>

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-05-09 at 16:13:52ID21844392
Topic

Miscellaneous Web Development

Participating Experts
5
Points
500
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ASP Shopping Cart ?
    Is there such a thing as a shop cart system written with ASP? If so, what do you recommend? My budget is very small. Thanks much.
  2. shopping cart
    I have a page that will display all the product and price that are available. I give user to select the qty and to it to cart . Like this .. Product_name Price Kuantiti Add to cart ============ ===== ======== ...
  3. Shopping Cart,
    I would like to have a shopping cart at my page do any of you guys have a shopping cart software or scripts that i could download or anybody knows how i could download parts for my hopping carts and manuals ideas thank yo u
  4. simple shopping cart
    I'm trying to create a simple web shopping cart and I have a question for you guys: How do you recommend I temporarily store the contents of a users shopping cart? Can I have an array or an object stored in the session? Or a temporary database table? I currently only hav...
  5. rs.eof
    <%@ page import="java.sql.*" %> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:sales"); Statement stmt = conn.createStatement(); String query = "Select * From info Whe...
  6. ASP Shopping Cart Questions
    I am getting ready to create a shopping cart with asp. But I have few quesitons as to how the payments get transfer? I have made shopping carts before with other scripting languages, however, I have never made the back-end to transfer the payment. How exactly does the payme...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Clever_BobPosted on 2006-05-09 at 17:09:08ID: 16644314

Its pretty hard to 'lock' a server to the extent that nobody else can view the site.

I'd say its more likely that the site suffers from a viewability issue - e.g. some browsers will deliver the response fine and others will crash. Are there any components that require java, cookies etc?

If you test the site with the same browser over and over is there an issue? If so, try changing the browser settings until it fails.

 

by: HypercubeTechPosted on 2006-05-09 at 17:16:16ID: 16644331

I haven't tried to access the site since i posted this about an hour ago.. now it times out and gives this

Microsoft OLE DB Provider for SQL Server error '80040e31'

Timeout expired

/includes/SQL.asp, line 81



hehe ok now i hit refresh and the site comes up fine..  i hit an item to add to cart, (which the link is on the secure.mysuperpages.com site)
and now it times out again.

 

by: HypercubeTechPosted on 2006-05-09 at 17:28:20ID: 16644372

now i hit refresh again on the page with the timeout expired error, and its added to the cart

 

by: joejenkinsjaxPosted on 2006-05-09 at 18:37:43ID: 16644607

Hmm.  That error is caused by a query timing out .. How long before you get that message?  Let's see your add to cart query or segment of code.  That could be your issue.  Outdated versions of MDAC can cause this or a poor server name lookup can prolong query time on systems where the database server is not the same as a the webserver because of a faulty switch, poor cabling or bad routing tables.  You might bounce this off the Verizon Support people since they can shed some more light on the back end configuration.  Let them know this was fine before the switch.

Joe Jenkins

 

by: kssoftwarePosted on 2006-05-09 at 21:30:14ID: 16645420

I ran a large Govt. database and had a lot of trouble over the years with a similar problem.  Joe is right - it is often due to out of date MDAC components although no matter when we upgraded the MDAC, the problem persisted.  Usually when this happened it was due to a lock happening on one of the tables.  You might try recasting your loop into a stored procedure, as this can help overcome the problem - you have opened your recordset as dynamic and also delete one of its records while in the loop ("delete from temp_IDs where..." - bypassing the recordset).  Here's a sample stored procedure (you might want to add some error handling, etc).  You would call it like this:
     adCmdStoredProc = &H0004
     cmdText = "spSessionRemove"
     set oCMD = server.CreateObject("ADODB.command")
     oCMD.CommandText = cmdText
     oCMD.CommandType = adCmdStoredProc
     oCMD.ActiveConnection = conn
     oCMD.Execute
     set oCMD = nothing
---------------------------------------------------
Create Procedure spSessionRemove()
As
      set nocount on
      delete from orders where SessionID IN (SELECT ID from temp_IDs
            WHERE DateDiff(day, [timestamp], getdate()) > 1)

      delete from addresses where SessionID IN (SELECT ID from temp_IDs
            WHERE DateDiff(day, timestamp, getdate()) > 1)
      delete from payment where SessionID IN (SELECT ID from temp_IDs
            WHERE DateDiff(day, timestamp, getdate()) > 1)
      delete from userinfo where SessionID IN (SELECT ID from temp_IDs
            WHERE DateDiff(day, timestamp, getdate()) > 1)
      -- finally, remove the sessionids:
      delete from temp_IDs
            WHERE DateDiff(day, timestamp, getdate()) > 1
      
      return
---------------------------------------------------

 

by: HypercubeTechPosted on 2006-05-09 at 22:24:31ID: 16645594

i'll give it a shot, thanks!   also, we have a support ticket opened with Verizon, but they are idiots

 

by: dukestaTAIPosted on 2006-05-10 at 03:42:43ID: 16647299

kssoftware brings up a great point with using Stored Procedures.  Also Maybe you could try using the ODBC SQL Provider instead of the OLE Provider to see if you get the same problem.  Here is an example:

connectionInfo = "Driver={SQL Server};Server=XXXXX;Database=XXXXX;Uid=XXXXX;Pwd=XXXXXX;"

Maybe this will help isolate the problem to MDAC.

 

by: joejenkinsjaxPosted on 2006-05-10 at 04:11:24ID: 16647448

The stored procedure and OLE providers are all great suggestions actually.  Using the stored will allow for shorter db access times per transaction.  That in itself will have an affect on overall performance.  

I'm glad you didn't tell us you were using a DSN. :)

I'm not even sure it's a lock issue though because in the initial posting it was explained that there was [maybe] 2-3 people in the store at a time.  75% or higher, depending on the store, of a user's time is browsing the store and not running lookups, etc.   If you're running into a lock issue with that few users you will definitely need to review the length of your SQL calls to the db.  Visit where connections are open and closed and keep the closed as long as possible.  It may not have been an issue with the old provider, but could be showing up in this case.  Either way, the stored procedure is a good idea for performance so I would definitely implement that either way.

Part of the Verizon ticket would definitely make sure they're running the latest DB engine drivers. and DAC's.  

:) Let us know how this comes out!
Joe Jenkins

 

by: jespiresPosted on 2006-05-16 at 09:42:15ID: 16692317

Just a comment by looking at the code.  I don't see you closing any of the DB connections.  You set the value to values to nothing, but that does not close the connections.  I actually open and close every connection as fast as I can when accessing data to prevent deadlocks like you are explaining.  You may be opening the DB with a lock..

Here is how I close the connections and recordsets and each query.

    rs1.close
    cn1.close
    set rs1 = nothing
    set cn1 = nothing

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...