PRB: DBExec() Cuts off Path/Filenames More Than 10 CharactersLast reviewed: June 27, 1995Article ID: Q109143 |
The information in this article applies to:
SYMPTOMSAfter you execute a DBExec() function and specify a path and table name greater than 10 characters, the filename is truncated after 10 characters and the file will be given the resulting name.
RESOLUTIONPrior to executing the DBExec() function with the SQL statement, use the SET DEFAULT TO command to point to the directory where the results of the query should go and then specify only the table name in the DBExec() function. If the SET DEFAULT TO command was used to set the directory where the program modules for the program are, use the SET PATH TO command to specify the directory where the program modules are and use the SET DEFAULT TO command to specify where the results should go. See below for a demonstration of the problem and its resolution.
MORE INFORMATIONThe following code reproduces the problem:
** The workaround would be to issue: ** ** SET PATH TO <Program Directory> ** SET DEFAULT TO <Result Directory> ** ** and then change the line that says: ** a=DBExec(handle,"select * from stores","c:\temp\test.dbf") ** to: ** a=DBExec(handle,"select * from stores","test.dbf") ** SET LIBRARY TO THE ODBC LIBRARY SET LIBRARY TO c:\foxwa\fpsql.fll ** ERRVAL=ERROR NUMBER, ERRMSG=ERROR MESSAGE ** IF AN ERROR IS RECEIVED THEN DBERROR() ** WILL BE CALLED AND THE ERROR NUMBER WILL BE ** STORED IN ERRVAL AND THE MESSAGE IN ERRMSG. PUBLIC errval PUBLIC errmsg errval=0 errmsg=' ' ** SPECIFY SOURCE NAME AS SEEN IN ODBC MANAGER. ** SPECIFY USER AND PASSWORD FOR SERVER. sourcename="test" user="sa" passwd="" ** GET A CONNECTION HANDLE. handle=DBConnect(sourcename,user,passwd) if handle > 0 WAIT WINDOW "Successfully Connected" else error=DBError(0,@errmsg,@errval) WAIT WINDOW STR(errval)+" "+errmsg DBDisconn(handle) endif ** SET VARIOUS OPTIONS FOR SESSION HANDLE. =DBSetOpt(handle,'Asynchronous',0) && Turn synchronous on =DBSetOpt(handle,'BatchMode',1) && Return all results at once =DBSetOpt(handle,'ConnTimeout',0) && wait forever if need be =DBSetOpt(handle,'Transact',1) && Turn Auto on =DBSetOpt(handle,'UseTable',1) && Put Results into a table ** USE THE PUBS DATABASE (A STANDARD DATABASE THAT COMES ** WITH SQL SERVER. a=DBExec(handle,"use pubs") if a > 0 WAIT WINDOW "NOW USING PUBS DATABASE" else error=DBError(handle,@errmsg,@errval) WAIT WINDOW STR(errval)+" "+errmsg endif ** PERFORM AN SQL SELECT AND PUT RESULTS IN C:\TEMP\TEST.DBF ** THE LINE BELOW WILL RESULT IN A FILE NAMED TE.DBF PLACED ** IN THE C:\TEMP DIRECTORY INSTEAD OF TEST.DBF PLACED ** IN C:\TEMP a=DBExec(handle,"select * from stores","c:\temp\test.dbf") if a > 0 WAIT WINDOW "SELECT * FROM STORES EXECUTED" BROWSE else error=DBError(handle,@errmsg,@errval) WAIT WINDOW STR(errval)+" "+errmsg endif ** RELEASE CONNECTION HANDLE AND LIBRARY. =DBDisconn(handle) SET LIBRARY TO |
Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b ODBC CK cut off
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |