Bug #10592 Driver's SQLAllocHandle on SQL_HANDLE_DBC failed
Submitted: 12 May 2005 12:30 Modified: 30 May 2013 12:35
Reporter: mark Richardson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:4.0.24-nt OS:Windows (windows web edition 2003 SP1)
Assigned to: CPU Architecture:Any

[12 May 2005 12:30] mark Richardson
Description:
after several hours of server activity the webserver will send this error

Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

[Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_DBC failed 

/include/Openconnection.asp, line 11 

********code from page with error**********
1)      <%
2)      If Not IsAdmin Then  
3)      Response.CacheControl = "no-cache"
3)      Response.AddHeader "Pragma", "no-cache"
4)      Response.Expires = -1
5)      End If
6)
7)      Response.AddHeader "P3P","CP=""ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT"""
8)       Set ObjDB = Server.CreateObject("ADODB.Connection")
9)       Set ObjRS = Server.CreateObject("ADODB.Recordset")
10)      Set ObjRS_No2 = Server.CreateObject("ADODB.Recordset")
11)      ObjDB.Open "DSN=IPDATANET"
12)
13)    Set ObjDBMapURL = Server.CreateObject("ADODB.Connection")
14)    ObjDBMapURL.Open "DSN=MapURL"
15)     %>

The page works fine for several thousand page requests but after the error occurs it can not be stopped by recycling the worker process of the web site, or restarting IIS, even restarting the MySQL service has no affect, the only resolution is to restart the server.

This page was changed to read;

<%
If session("Admin_ClientID") = "" Then
	Response.CacheControl = "no-cache"
	Response.AddHeader "Pragma", "no-cache"
	Response.Expires = -1
End If
Response.AddHeader "P3P","CP=""ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT"""

If not isObject(objRS) Then
	Set ObjRS = Server.CreateObject("ADODB.Recordset")
End if
If ObjRS.state <> 0 Then
	ObjRS.close
End If

If not isObject(ObjRS_No2) Then
	Set ObjRS_No2 = Server.CreateObject("ADODB.Recordset")
End If
If ObjRS_No2.state <> 0 Then
	ObjRS_No2.close
End If

If not IsObject(ObjDB) Then
    set ObjDB=Server.CreateObject("ADODB.Connection")
    ObjDB.ConnectionTimeout = 15
    ObjDB.CommandTimeout = 10
    ObjDB.Mode = 3 'adModeReadWrite 
    If ObjDB.state = 0 Then
		ObjDB.Open "DSN=TREASUREBOX"
    End If
End If

If not IsObject(ObjDBMapURL) Then
    set ObjDBMapURL=Server.CreateObject("ADODB.Connection")
    ObjDBMapURL.ConnectionTimeout = 15
    ObjDBMapURL.CommandTimeout = 10
    ObjDBMapURL.Mode = 3 'adModeReadWrite 
    If ObjDBMapURL.state = 0 Then
		ObjDBMapURL.Open "DSN=MapURL"
    End If
End If

%>

this has stopped the same error occuring but now we get another error.

 Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

Unspecified error 

/include/GetClient.asp, line 3 

******code from GetClient.asp**********
1)     <%
2)     Sql =  "Select * from shopsite_hostheaders"
3)     ObjRS.Open Sql, ObjDB
4)     If Not objRS.EOF Then
5)     	Do While Not ObjRS.EOF
................................

***********************************

this is the first Recordset that tyhe page is trying to open, if that makes any difference.

I am using windows 2003 SP1
MyODBC: 2.50.39
MySQL: 4.0.24-nt

I`ve tried using the the 3.51.11 drivers but i seem to get errors after about 3 page requests.

like:
error '80020009' 
Exception occurred. 

/includes/Functions.asp, line 114
***********code from Functions***********
100)     Function SmartLinks(HTMLContent)
101)      Set regEx = New RegExp   ' Create a regular expression.
102)      regEx.Pattern = "[/a-z0-9=&]+.asp\?[a-z0-9=&]+"
103)      regEx.IgnoreCase = True   ' Set case insensitivity.
104)      regEx.Global = True   ' Set global applicability.
105)      Set Matches = regEx.Execute(HTMLContent)   ' Execute search.
106)      For Each Match in Matches   ' Iterate Matches collection.
107)      MatchValue = Match.Value		
108)      If Left(Match.Value,1) = "/" Then
109)       Temp_MatchValue = Match.Value
110)      Else
111)       Temp_MatchValue = "/"& Match.Value
112)      End If
113)      ALT_Link = AlternativeLink(Temp_MatchValue)
114)      HTMLContent = Replace(HTMLContent,MatchValue,ALT_Link)
115)      Next
116)      SmartLinks = HTMLContent
117)     End Function

and

Microsoft OLE DB Provider for ODBC Drivers error '80040e21' 

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. 

/include/GetClient.asp, line 7 
***************code from GetClient.asp **************
<%
Sql =  "Select * from shopsite_hostheaders"
ObjRS.Open Sql, ObjDB
If Not objRS.EOF Then
	Do While Not ObjRS.EOF
		For Each objField in objRS.Fields
			If Instr(objField.Name,"SERVER_NAME") <> 0 and objField.Value = Request.ServerVariables("SERVER_NAME") Then

How to repeat:
using the the MyODBC drivers 3.51.11 the error appears after just a couple of page requests to any page on the site.

Suggested fix:
driver fix, or ducumentation on resolution
[15 May 2005 9:16] Vasily Kishkin
As far as I know other databases have same problem with SQL_HANDLE_DBC. Could you try with other databases (I mean SQL Server and so on) ?
[15 Jun 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[30 May 2013 12:35] Bogdan Degtyariov
I'm closing this bug because I can not continue without feedback from the reporter. If you have new info, please reopen the report.