FIX: You may receive error messages when you have an application that connects to Visual FoxPro data by using OLE DB Provider for Visual FoxPro (896170)



The information in this article applies to:

  • Microsoft Visual FoxPro 9.0 Professional Edition
  • Microsoft OLE DB Provider for Visual FoxPro 9.0
  • Microsoft Visual FoxPro 8.0 SP1
  • Microsoft Visual FoxPro 8.0
  • Microsoft OLE DB Provider for Visual FoxPro 8.0
  • Microsoft Visual FoxPro for Windows 7.0 SP1
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft OLE DB Provider for Visual FoxPro 7.0

SYMPTOMS

Consider the following scenario. You have an application that connects to Microsoft Visual FoxPro data by using Microsoft OLE DB Provider for Visual FoxPro. If this application depends on a specific default directory being set, you may receive error messages.

For example, when a Microsoft Visual Basic .NET application tries to perform a compilation, the application may fail, and you may receive the following error message:
"Cannot execute program"

CAUSE

When OLE DB Provider for Visual FoxPro executes SQL commands, OLE DB Provider for Visual FoxPro temporarily changes the application default directory to the path that is contained in the connection string Data Source property of the application. This change occurs only when you use a connection string Data Source property that is configured for free tables.

OLE DB Provider for Visual FoxPro executes SQL commands in the following steps:
  1. The existing application default directory is stored.
  2. The application default directory is changed to the path that is contained in the connection string Data Source property. The data source must be a free table directory.
  3. The command is executed.
  4. The previous application default directory is restored.
If you have multiple clients connecting at the same time, the application default directory may be changed to the path that is contained in the connection string Data Source property for the duration of the application process.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Visual FoxPro 9.0 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time   Version     Size       File name
   -------------------------------------------------------
   23-Mar-2005  02:56  9.0.0.2722  1,769,472  Vfpoledb.dll

WORKAROUND

To work around this problem, use one of the following methods that do not require the hotfix:
  • Use a connection string Data Source property that references a Visual FoxPro database (.dbc) file instead of a connection string that references a free table directory.
  • Use the full path of each table in the following SQL statements:
    • The SELECT statement
    • The INSERT statement
    • The UPDATE statement
    • The DELETE statement
    For example, consider the following code.
    myOleDbConnection = New OleDbConnection("provider=vfpoledb.1;data source=\\server\share\datadir")
    myOleDbCommand = New OleDbCommand("SELECT  * from mytable", myOleDbConnection)
    Change this code to the following code.
    myOleDbConnection = New OleDbConnection("provider=vfpoledb.1;data source=\\server\share\datadir")
    myOleDbCommand = New OleDbCommand("SELECT  * from \\server\share\datadir\mytable", myOleDbConnection)

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Steps to reproduce the problem

The following steps reproduce the change in the application default directory. The following steps do not reproduce the example error message that is mentioned in the "Symptoms" section.
  1. Create a new Microsoft Visual Basic .NET project. Click ASP.NET Web application, and then name the new project VBNetVFPOLEDBPath.
  2. After the project is created, double-click the surface of WebForm1 to open the code window.
  3. At the top of the code window, locate the following line of code.
    Public Class WebForm1
    Before this line of code, add the following line of code.
    Imports System.Data.OleDb
  4. In Webform1.aspx, add the following code to the Sub Page_Load function.
    Dim myDataReader As OleDbDataReader
    Dim myOleDbConnection As OleDbConnection
    Dim myOleDbCommand As OleDbCommand
    
    Dim DataPath As String
    
    DataPath = "\\server\share\data\" ' Must include trailing backslash
    
    Response.Write("Before - " + CurDir() + "<BR>")
     
    myOleDbConnection = New OleDbConnection("provider=vfpoledb.1;data source=" + DataPath)
    
    ' Make SELECT return default directory and current path
    myOleDbCommand = New OleDbCommand("SELECT [Default=]+Sys(5)+sys(2003)+[ Path=]+set([path]),  * from mytable", myOleDbConnection)
    
    myOleDbConnection.Open()
    
    Response.Write("Middle - " + CurDir() + "<BR>")
    
    myDataReader = myOleDbCommand.ExecuteReader()
    myDataReader.Read()
    
    Response.Write(myDataReader.GetString(0).ToString() + "<BR>")
    Response.Write("After - " + CurDir() + "<BR>")
    myDataReader.Close()
    myOleDbConnection.Close()
    
  5. Change the path in the following line of code to reference a share to which you have access and that contains a Visual FoxPro free table.
    DataPath = "\\server\share\data\" 
    Change the table name in the following line of code to the free table.
    myOleDbCommand = New OleDbCommand("SELECT [Default=]+Sys(5)+sys(2003)+[ Path=]+set([path]),  * from mytable", myOleDbConnection)
  6. Build the solution.
  7. Call the page from Microsoft Internet Explorer on two computers at the same time. To do this, follow these steps:
    1. Type the following URL:

      http://servername/VBNetVFPOLEDBPath/webform1.aspx

    2. To refresh the pages, press the F5 key several times on both computers at the same time.
At first, the output in Internet Explorer on both computers looks similar to the following output:

Before - c:\windows\system32\inetsrv
Middle - c:\windows\system32\inetsrv
Default=\\SERVER\SHARE\DATA\ Path=\\SERVER\SHARE\DATA\
After - c:\windows\system32\inetsrv

After you press F5 several times, the output changes to the following output:

Before - \\SERVER\SHARE\DATA\
Middle - \\SERVER\SHARE\DATA\
Default=\\SERVER\SHARE\DATA\ Path=\\SERVER\SHARE\DATA\
After - \\SERVER\SHARE\DATA\

Note In this output, \\SERVER\SHARE\DATA\ is a placeholder for the path that you specified in step 5.

Modification Type:MinorLast Reviewed:7/25/2006
Keywords:kbQFE kbpubtypekc KB896170 kbAudDeveloper