We help IT Professionals succeed at work.

ASP include closing conn

AndersonHitchen
on
Hi

I have an include that is set at the footer of my pages to close connections. It is returning the following error

Microsoft VBScript runtime error '800a01a8'
Object required: 'DRIVER={MySQL ODBC 5'
/carsauce/includes/incClose.asp, line 2

The include code is as follows
MM_Connilease_STRING.Close()  
Set Connilease = Nothing

Open in new window


It's an old site that I have been ask to get working, looked for the error problem probably something simple but I can not see it.

Cheers Marcus
Comment
Watch Question

Big MontyWeb Ninja at large

Commented:
Try this:


If MM_Connilease_STRING.State <> 0 then
   MM_Connilease_STRING.Close()  
End if
Set Connilease = Nothing
Big MontyWeb Ninja at large

Commented:
this code is assuming is some kind of object, like a recordset or connection object. you'll probably want to check the other object and see if it's "state" is not closed (state = 0):

If MM_Connilease_STRING.State <> 0 then
   MM_Connilease_STRING.Close()  
End if
if Connilease  <> 0 then
   Set Connilease = Nothing
end if

Author

Commented:
Hi Big Monty

Microsoft VBScript runtime error '800a01a8'
Object required: 'DRIVER={MySQL ODBC 5'
/carsauce/includes/incClose.asp, line 5


Thats the error I got with that

Cheers M
Big MontyWeb Ninja at large

Commented:
what kind of objects are MM_Connilease_STRING and Connilease?

Author

Commented:
connilease is the connection that opens the recordset for the search results. MM_connilease_string is the main site connection which is included at the top of each page.
It is used in the dropdown select search.

Cheers
Big MontyWeb Ninja at large

Commented:
forgot the check on the "state" property for the second object, it should be:

If MM_Connilease_STRING.State <> 0 then
   MM_Connilease_STRING.Close()  
End if
if Connilease.State  <> 0 then
   Set Connilease = Nothing
end if

Author

Commented:
Hi

Changed it to that but still getting the same error on line 5  

Microsoft VBScript runtime error '800a01a8'
Object required: 'DRIVER={MySQL ODBC 5'
/carsauce/includes/incClose.asp, line 5

I can not see any other connections created

Cheers M
Big MontyWeb Ninja at large

Commented:
Then that means those objects are destroyed elsewhere in another page. If you are getting the errors in all of your pages then you can just remove those lines of code.
Web Ninja at large
Commented:
Otherwise you can try using the IsObject function:

If IsObject( MM_Connilease_STRING) then
    If MM_Connilease_STRING.State <> 0 then
       MM_Connilease_STRING.Close()  
    End if
End if

If IsObject( Connilease) then
   if Connilease.State  <> 0 then
       Set Connilease = Nothing
    end if
End if

Author

Commented:
That worked thank you. could you explain why this is rather than the one that was being used?

thanks again M

Author

Commented:
resolved the issue thanks
Big MontyWeb Ninja at large

Commented:
this works because it first checks to see if MM_Connilease_STRING is an object in memory (if it isn't and you try to close something on an object that doesn't exist, it fails, right?), if it exists then it it runs through the code to destroy the object