Microsoft KB Archive/896170

= 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 =

Article ID: 896170

Article Last Modified on 11/15/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 9.0 Professional Edition
 * Microsoft OLE DB Provider for Visual FoxPro 9.0
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft OLE DB Provider for Visual FoxPro 8.0
 * Microsoft Visual FoxPro 7.0 Service Pack 1
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * 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:

&quot;Cannot execute program&quot;



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. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Visual Fox Pro 9.0 service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

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</li> The DELETE statement</li></ul>

For example, consider the following code. myOleDbConnection = New OleDbConnection(&quot;provider=vfpoledb.1;data source=\\server\share\datadir&quot;) myOleDbCommand = New OleDbCommand(&quot;SELECT * from mytable&quot;, myOleDbConnection) Change this code to the following code. myOleDbConnection = New OleDbConnection(&quot;provider=vfpoledb.1;data source=\\server\share\datadir&quot;) myOleDbCommand = New OleDbCommand(&quot;SELECT * from \\server\share\datadir\mytable&quot;, myOleDbConnection) </li></ul>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_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 &quot;Symptoms&quot; section. <ol> Create a new Microsoft Visual Basic .NET project. Click ASP.NET Web application, and then name the new project VBNetVFPOLEDBPath.</li> After the project is created, double-click the surface of WebForm1 to open the code window.</li>  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 </li>  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 = &quot;\\server\share\data\&quot; ' Must include trailing backslash

Response.Write(&quot;Before - &quot; + CurDir + &quot;<BR>&quot;) myOleDbConnection = New OleDbConnection(&quot;provider=vfpoledb.1;data source=&quot; + DataPath)

' Make SELECT return default directory and current path myOleDbCommand = New OleDbCommand(&quot;SELECT [Default=]+Sys(5)+sys(2003)+[ Path=]+set([path]), * from mytable&quot;, myOleDbConnection)

myOleDbConnection.Open

Response.Write(&quot;Middle - &quot; + CurDir + &quot;<BR>&quot;)

myDataReader = myOleDbCommand.ExecuteReader myDataReader.Read

Response.Write(myDataReader.GetString(0).ToString + &quot;<BR>&quot;) Response.Write(&quot;After - &quot; + CurDir + &quot;<BR>&quot;) myDataReader.Close myOleDbConnection.Close </li>  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 = &quot;\\server\share\data\&quot; Change the table name in the following line of code to the free table. myOleDbCommand = New OleDbCommand(&quot;SELECT [Default=]+Sys(5)+sys(2003)+[ Path=]+set([path]), * from mytable&quot;, myOleDbConnection) </li> Build the solution.</li> Call the page from Microsoft Internet Explorer on two computers at the same time. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Type the following URL:

http:// /VBNetVFPOLEDBPath/webform1.aspx

</li> To refresh the pages, press the F5 key several times on both computers at the same time.</li></ol> </li></ol>

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= Path=

After - c:\windows\system32\inetsrv

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

Before -

Middle -

Default= Path=

After -

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

Keywords: kbhotfixserver kbqfe kbpubtypekc KB896170

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.