Microsoft KB Archive/288863

= ASP/COM+ solutions using Visual FoxPro ODBC driver may fail under stress =

Article ID: 288863

Article Last Modified on 8/15/2005

-

APPLIES TO


 * Microsoft Visual Studio 6.0 Enterprise Edition
 * Microsoft Visual Studio 6.0 Service Pack 4
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0
 * Microsoft Active Server Pages 4.0
 * Microsoft ActiveX Data Objects 1.0
 * Microsoft ActiveX Data Objects 1.5
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.01
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6

-



This article was previously published under Q288863



SYMPTOMS
When designing a solution that uses the Visual FoxPro ODBC (VFPODBC) driver, developers may find that their COM objects fail (hang or crash) when the solution is under heavy load. This occurs regardless of the version of the VFPODBC driver.



CAUSE
COM objects that are developed with Microsoft Visual Basic, Microsoft Visual C++, or other development languages are widely used as middle-tier business objects in large-scale, multiuser solutions. These COM objects are often resident in MTS/COM+ packages, and use the VFPODBC driver to query and update data from Microsoft Visual FoxPro and Microsoft FoxPro 2. tables.

The problem with this design is that the Visual FoxPro ODBC driver is not thread-safe, and as a result, MTS/COM+ (or the objects themselves if they are stand-alone) can fail.

Note The Drvvfp.hlp and Vfpodbc.txt files that are installed with the driver both state that the VFPODBC driver is thread-safe; this is incorrect.



WORKAROUND
To work around this problem, you can do one of the following:  Use a multithreaded COM DLL (MTDLL) built with Microsoft Visual FoxPro 6.0 Service Pack 3 or later. VFP 6.0 SP3 MTDLLs can manipulate FoxPro data using the native FoxPro language and are thread-safe. Move the FoxPro data from the FoxPro tables to another data source (such as SQL Server). Utilize a thread-safe ODBC driver or OLE DB provider for that alternate data source from the problematic COM object. Use the Microsoft OLE DB Provider for Visual FoxPro. The Visual FoxPro OLE DB Provider is thread-safe and may be used without causing failures. Currently, the Visual FoxPro OLE DB Provider is included with Visual FoxPro 7.0 and later versions. The Visual FoxPro OLE DB Provider is also available free for download from Microsoft. For more information, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn.microsoft.com/vfoxpro/downloads/updates/default.aspx





MORE INFORMATION
If the solution using the VFPODBC driver is not under heavy usage, this problem can potentially be resolved by doing the following:
 * 1) Make sure that the programmatic connection string or ODBC data source name (DSN) that uses the VFPODBC driver does not have the Fetch Data In Background option selected. The BackgroundFetch attribute keyword in connection strings should equal NO, or the Fetch Data In Background option should not be selected when setting up a DSN in ODBC Data Source Administrator.
 * 2) Ensure the validity of the TMP and TEMP system environmental variables on the computer that hosts the VFPODBC driver. The VFPODBC driver creates temporary files as it works, and it uses these environmental variables to determine where to write the files. If these variables are not present, problems with nonexistent directories or drives with insufficient free safe can occur.

