Object required: '[undefined]' Error

I have an asp page which has this at line 214:  
Set rs = RunStoredProc("Select top 1 from tblName", "query")
  ... some code here
rs.close
Set rs = Nothing

This page also contains javascript to refresh this page every 60 seconds.  There are no problems with this page, but when the page is left up for a period of time .. ie: 30 minutes or longer, it will fail to refresh and displays the error mesage below.  I am not sure why this is happening.  Is there a solution to this?  Thanks.


The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

----------------------------------------------------------------------------
----

Please try the following:

Click the Refresh button, or try again later.

Open the www.first-watch.us home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

----------------------------------------------------------------------------
----

Technical Information (for support personnel)

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[undefined]'
/alert_status2.asp, line 214


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)

Page:
GET /alert_status2.asp

Time:
Tuesday, April 27, 2004, 5:01:53 AM


More information:
Microsoft Support
 
wunyuAsked:
Who is Participating?
 
moduloConnect With a Mentor Commented:
Closed, 100 points refunded.

modulo
Community Support Moderator
Experts Exchange
0
 
leechoonhweeCommented:
I think your connection timed out. When you refresh the page, does it open a new connection to the DB?
0
 
wunyuAuthor Commented:
This is the code for that function.  So whenever the page reloads, it calls this function again to run the query.  From this function, it looks like a new connection is created each time.

Function RunStoredProc(StoredProcedure, Params)
    Dim adoCmd, adoConn
      
      Set adoConn      = Server.CreateObject("ADODB.Connection")
      With adoConn
            .ConnectionTimeout = 30
            .CommandTimeout = 15
            .CursorLocation      = 3
            .Open ConnectionString
      End With
      
      Set adoCmd      = Server.CreateObject("ADODB.Command")
      With adoCmd
            On Error Resume Next
            .ActiveConnection = adoConn
            .CommandText = StoredProcedure
            If LCase(Params(0)) = "query" Then
                  .CommandType = 1
                  Set RunStoredProc = .Execute()
            ElseIf IsNull(Params(0)) Then
                  .CommandType = 4
                  Set RunStoredProc = .Execute()
            Else
                  .CommandType = 4
                  Set RunStoredProc = .Execute( ,Params)
            End If
            If Err.Number <> 0 Then
                  'Write to error log file here if necessary
            End If
            On Error Goto 0
      End With
      Set adoCmd = Nothing
      Set adoConn = Nothing
End Function
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
leechoonhweeCommented:
Well. Your stored procedure did open a connection to the DB however the main recordset in the asp did not open the connection. You should have

Open conn
Open rs

Set rs = RunStoredProc("Select top 1 from tblName", "query")
  ... some code here
rs.close
Set rs = Nothing
Set Conn = Nothing

This way, the connection will be opened on every refresh.
0
 
wunyuAuthor Commented:
If I added this code before Set rs = RunStoredProc(...):

      'Open Connection
      Set adoConn      = Server.CreateObject("ADODB.Connection")
      With adoConn
            .ConnectionTimeout = 300      'used to be 30s, now 300s
            .CommandTimeout = 300      'used to be 15s, now 300s
            .CursorLocation      = 3
            .Open ConnectionString
      End With
      
      Set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open ???

What do I pass in as parameters to rs.Open?
I do not understand how rs uses the new adoConn connection if my next statement should be

Set rs = RunStoredProc("Select top 1 from tblName", "query")
  ... some code here
rs.close
Set rs = Nothing
Set Conn = Nothing

Am I missing something?

0
 
wunyuAuthor Commented:
Thanks leechoonhwee but didn't know how to use your solution.  How I solved it was setting the recordset to nothing beforehand.  I resume on error and check if the recordset is nothing.  If it is, I display a timeout message.  If it's not nothing, then I display the results as usual.  This way, at least the rest of the page shows and I won't get that Object required: '[undefined]' Error page.
0
 
leechoonhweeCommented:
   Dim objConn, intParam
    intParam = 2
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objConn.Open "NWind" , "Guest", "welcome"

  ' Execute, Getstring and Write all on one line:
    Response.Write objConn.Execute("pGetEmployees " & intParam).GetString()

    Set objConn = Nothing


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.