TDbOdbcDirect problem

TDbOdbcDirect problem

Postby Rimantas » Fri Nov 18, 2005 9:44 am

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 .
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Postby James Bott » Fri Nov 18, 2005 4:54 pm

Try this to get the temp directory.

Code: Select all  Expand view
// 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Rimantas » Mon Nov 21, 2005 1:37 pm

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 .
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Postby Antonio Linares » Tue Nov 22, 2005 9:48 am

Rimantas,

Please try this cTempFile() source code:

Code: Select all  Expand view
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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rimantas » Tue Nov 22, 2005 2:27 pm

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 .
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests