PRB: Accessing SQL Database Fails on Second AttemptID: Q166659
|
One of the following error occurs when trying to access a SQL database via
Active Server Pages (ASP) under Internet Informaton Server (IIS) 3.0:
Error '80004005' Microsoft OLE DB Provider for ODBC Drivers error '80040e21', Errors Occurred
-or-
The error occurs on the second access to the data. For example, using a form generated by the DataForm Wizard clicking on the ">>" button to view the next 10 records results in the error described above.80004005: ConnectionWrite(GetOverLappedResult)
When the allow Anonymous User context is turned off, Windows NT is closing the pipe
to SQL Server after the first request is complete. This is because the
first connection to SQL Server is made under the IIS Anonymous User
account. IIS then either impersonates the browser client on that same
thread, or tries to access the connection on a different thread that is
running in the impersonated user context. In either case Windows NT would detect
the attempt to use a network named pipe handle that had been opened in a
different user context and force the pipe closed, per its security rules.
When the connections are viewed on the SQL Server with a network monitor, a
name pipe close request comes from Windows NT, causing the error in the Web
browser.
There are two relatively easy workarounds:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<% If IsEmpty(Session("rsConn")) Then
Set ISSQL65 = Server.CreateObject("ADODB.Connection")
ISSQL65.Open "DSN=pubs;UID=sa;PWD=;"
Set cmdTemp = Server.CreateObject("ADODB.Command")
cmdTemp.CommandText = "authors"
cmdTemp.CommandType = 2
Set cmdTemp.ActiveConnection = ISSQL65
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open cmdTemp, , 1, 3
Else
Set RS = Session("rsConn")
End If %>
<% Response.Write RS.EOF & " " & RS.BOF & "<br>"%>
<% If not RS.EOF Then %>
<% RS.MoveNext %>
<%= RS(0) %><br>
<%= RS(1) %><br>
<%= RS(2) %><br>
<% Else %>
End Of File reached on Recordset<BR>
<% End If %>
<% Set Session("rsConn") = RS %>
</BODY>
</HTML>
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
http://support.microsoft.com/support/vinterdev/
Keywords : kbASP kbNTOS400 kbSQLServ kbVisID kbVisID100 kbVisID600 kbGrpASP VIServer
Version : WINDOWS:1.0,6.0; winnt:3.0,4.0,6.5
Platform : WINDOWS winnt
Issue type : kbprb
Last Reviewed: May 4, 1999