Page 1 of 1

TDbOdbcDirect problem

Posted: Fri Nov 18, 2005 9:44 am
by Rimantas
Hi !

It seems that it's a problem with this class . I reviewed and found that in Open method it can't open temporary dbf . It seems that this is related to this :
DEFAULT ::cFileName := cTempFile(GetEnv("TEMP"),"DBF")

This GetEnv() work OK ?

With best regards ! Rimantas .

Posted: Fri Nov 18, 2005 4:54 pm
by James Bott
Try this to get the temp directory.

Code: Select all

// Returns path to windows temp directory
GetTempDir()
   local cDir   := GetEnv("TEMP")
   if empty(cDir)
      cDir := GetEnv("TMP")
   endif
   if Right( cDir, 1 ) == "\"
      cDir = SubStr( cDir, 1, Len( cDir ) - 1 )
   endif
   if !empty(cDir)
      if !lIsDir(cDir)
         cDir := GetWinDir()
      endif
   else
      cDir := GetWinDir()
   endif
return cDir

Posted: Mon Nov 21, 2005 1:37 pm
by Rimantas
Hello James ! Thanks for your reply . But I found that the problem isn't here . It's cTempFile() function :

function cTempFile() // returns a temporary filename
local cFileName
static cOldName
while File( ( cFileName := StrTran( Time(), ":", "" ) ) ) .or. ;
cFileName == cOldName
end
cOldName = cFileName
return cFileName

This function is without incoming arguments .

METHOD Open() CLASS TDbOdbcDirect
local aFields
local nLen, n
DEFAULT ::cFileName := cTempFile(GetEnv("TEMP"),"DBF") ,;
::cAlias := ""

In TDbOdbcDirect method Open() this function is with arguments . But the arguments isn't working and I get an error :

Error description: Error DBCMD/1010 Illegal characters in alias: ::cAlias
Called from DBUSEAREA(0)
Called from TDBODBCDIRECT:OPEN(0)

Antonio , do you have correct version of this function ?

With best regards ! Rimantas .

Posted: Tue Nov 22, 2005 9:48 am
by Antonio Linares
Rimantas,

Please try this cTempFile() source code:

Code: Select all

function cTempFile( cPath, cExtension )        // returns a temporary filename

   local cFileName

   static cOldName

   DEFAULT cPath := "", cExtension := ""
   
   if ! "." $ cExtension
      cExtension = "." + cExtension
   endif   

   while File( cFileName := ( cPath + StrTran( Time(), ":", "" ) ) + cExtension ) .or. ;
         cFileName == cOldName
   end

   cOldName = cFileName

return cFileName

Posted: Tue Nov 22, 2005 2:27 pm
by Rimantas
Antonio Linares wrote:Rimantas,

Please try this cTempFile() source code:

[/code]
Excuse me , Antonio , the function is working OK :-)) . I forget to set DBFFPT lib , because some fields in SQL database are as "MEMO" and so USE command didn't worked . Today I found the reason of that problem and now all is working OK . Your TDBOdbcDirect works fine now .. :-))

With best regards ! Rimantas .