Microsoft KB Archive/115728

{| = BUG: SIMBA.DLL ODBC Driver Resets FoxPro Default Directory =
 * width="100%"|

ID: Q115728

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
 * Microsoft FoxPro Connectivity Kit, versions 2.5, 2.5a, 2.5b, 2.6
 * ODBC Desktop Driver SIMBA.DLL, version 1.01.1928

SYMPTOMS
After SIMBA.DLL has been used to interact with either a .CSV or .TXT file, the FoxPro default directory is set to the location of the data file.

RESOLUTION
To work around this problem, do the following:

1. Use SYS(2003) to store the current directory to a memory variable:

curdir = SYS(2003) 2. Execute the ODBC code that uses the SIMBA.DLL Text driver. 3. Issue a SET DEFAULT TO statement to switch back to the original

directory:

SET DEFAULT TO &curdir

STATUS
Microsoft has confirmed this to be a problem with the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION
SIMBA.DLL, the single-tier ODBC driver used to access data from text files, processes information from any of four different file formats: CSV (Comma- Separated Value) Delimited, Tab Delimited, Custom Delimited, or Fixed Length. Regardless of the file format chosen for the Data Source in the ODBC Driver Manager Setup dialog box, a call to the driver results in a switch of FoxPro's default directory to the directory in which the data source file resides.

Steps to Reproduce Problem
1. In Control Panel, open the ODBC Driver Manager and set up the "Text

Files (*.txt; *.csv)" driver with a Data Source name of "Simba Test" and  a directory name of "c:\\mytext". 2. Copy some text files (TEXT1.CSV, TEXT2.CSV, and so on) to   C:\\MYTEXT. The contents of the files do not matter. 3. Make sure FPSQL.FLL is in the FoxPro program directory,   c:\. 4. Start FoxPro and set the default FoxPro directory:      SET DEFAULT TO c:\ 5. In the Command window, type:      MODIFY COMMAND simba 6. Type the following lines of code:      * Program: SIMBA.PRG

* Initialize

SET LIBRARY TO SYS(2004)+"FPSQL.FLL" PUBLIC errval, errmsg, handle errval=0 errmsg="" sourcename="Simba Test" user="" passwd=""

* Connect

handle = DBCONNECT(sourcename,user,passwd) IF handle > 0 WAIT WINDOW "Successfully Connected" NOWAIT ELSE error = DBERROR(0,@errmsg,@errval) WAIT WINDOW STR(error)+" "+STR(errval)+" "+errmsg ENDIF

* View tables (text files) out there (TEXT1.CSV, TEXT2.CSV, etc.)

err=DBTABLES(handle,"'TABLE'") DO errhand WITH err,"DBTABLES" IF err>0 BROWSE ENDIF

* Disconnect

err=DBDISCONN(handle) DO errhand WITH err,"DBDisconn" SET LIBRARY TO     CLOSE ALL

* Error handler

PROCEDURE errhand PARAMETERS err,command IF err > 0 WAIT WINDOW ALLTRIM(UPPER(command))+" Completed Successfully" ; NOWAIT ELSE WAIT WINDOW UPPER(COMMAND)+" NOT Completed" error=DBERROR(handle,@errmsg,@errval) WAIT WINDOW STR(error)+" "+STR(errval)+" "+errmsg ENDIF RETURN 4. Press CTRL+W to close and save the program. 5. In the Command window, type:

DO simba.prg

The program makes a connection to the data source and displays a Browse window of tables (text files TEXT1.CSV, TEXT2.CSV, and so on). 7. Press CTRL+W to close the Browse window. 8. In the Command window, type

? SYS(2003)

and look at the line printed in the desktop. The default directory, which is returned by SYS(2003), has changed from "c:\" to "c:\\mytext".