ODBC trace is unreliable in a multithreaded IIS environment (836072)



The information in this article applies to:

  • Microsoft ODBC SDK
  • Microsoft ODBC SDK 2.10c
  • Microsoft Internet Information Services version 6.0
  • Microsoft Internet Information Services version 5.1
  • Microsoft Internet Information Services 5.0
  • Microsoft Active Server Pages

SYMPTOMS

If you try to trace an ODBC connection in a multithreaded Internet Information Services (IIS) environment, you may receive an empty log file, or a log file may not be created at all.

CAUSE

The multithreaded IIS environment does not support ODBC tracing.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

  1. Create a Data Source Name (DSN). To do this, follow these steps:
    1. In Control Panel, click Administrative Tools, and then click Data Sources (ODBC). The ODBC Data Source Administrator dialog box appears.
    2. On the System DSN tab, click Add. The Create New Data Source dialog box appears.
    3. Double-click SQL Server in the Driver Name list. The Create a New Data Source to SQL Server dialog box appears.
    4. In the Name box, type mydatasource.

      Notemydatasource is a placeholder for the system DSN.
    5. In the Description box, type the description of the data source.
    6. In the Server box, type the server address or select the server that you want to connect to.
    7. Click Finish, and then click OK. The DSN appears in the ODBC Data Source Administrator dialog box.
    8. Click OK.
  2. Create an Active Server Pages (ASP) page. To do this, follow these steps:
    1. Create a folder on the desktop of your computer, and then name the folder MyWeb.
    2. Paste the following code in Notepad:
      <HTML>
      <HEAD><TITLE>ASP Database Connection</TITLE></HEAD>
      <BODY BGCOLOR=white>
      <H1>Northwind Database Contacts</H1>
      <%
      Dim Connect, selectSQL, RecSet 
      Set Connect = CreateObject ("ADODB.Connection")
      Connect.Open "DSN=<mydatasource>" 
      selectSQL = "SELECT * FROM Customers" 
      Set RecSet = Connect.Execute (selectSQL)
      If NOT RecSet.EOF THEN
      DO UNTIL RecSet.EOF
      Response.Write RecSet("Companyname") & ", " & RecSet("Contactname") & "<BR><BR>"
      RecSet.MoveNext
      Loop
      End If
      RecSet.Close
      Connect.Close
      Set RecSet = Nothing
      Set Connect = Nothing
      %>
      </BODY></HTML>
    3. Name this file myWeb.asp, and then save it in the MyWeb folder.
  3. Create a virtual directory. To do this, follow these steps:
    1. Click Start, and then click Run. The Run dialog box appears.
    2. In the Open box, type inetmgr, and then click OK. The Internet Information Services window appears.
    3. Double-click servername.

      Noteservername is a placeholder for the name of the server.
    4. Expand Web Sites under servername, right-click Default Web Site, point to New, and then click Virtual Directory.
    5. In the Virtual Directory Creation Wizard, click Next.
    6. In the Alias box, type foldername, and then click Next.

      Notefoldername is a placeholder for the virtual directory that you create on your computer that is running Internet Information Services.
    7. Click Browse, locate the MyWeb folder that you created on the desktop, and then click Next.
    8. Verify the access permissions, and then click Next.
    9. Click Finish to create the virtual directory.
  4. Trace the ODBC connection. To do this, follow these steps:
    1. In Control Panel, click Administrative Tools.
    2. Click Data Sources (ODBC), and then click the Tracing tab.
    3. In the Log file Path box, type C:\Sql.log to create a log file.

      NoteSql.log is a placeholder for the log file that the computer creates to log the results when you connect to the database through a program.
    4. Click Start Tracing Now and do not close the ODBC Data Source Administrator dialog box.
    5. Open the myWeb.asp file in Internet Explorer.
    6. After the page is loaded, click Stop Tracing Now in the ODBC Data Source Administrator dialog box.
    7. Open the Sql.log log file. You find the result that is mentioned in the "Symptoms" section.

Modification Type:MinorLast Reviewed:8/18/2005
Keywords:kbASPObj kbUser kbIISAM kbprb KB836072 kbAudDeveloper kbAudEndUser