SavetoDbf() de MariaDb tiene error con dbUseArea() (SOLUCIONADO)

Post Reply
User avatar
CARLOS ATUNCAR
Posts: 195
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru
Been thanked: 2 times
Contact:

SavetoDbf() de MariaDb tiene error con dbUseArea() (SOLUCIONADO)

Post by CARLOS ATUNCAR »

Saludos me esta pasando un problema que hasta hace unas pruebas no pasaba

uso la clase TPUBLIC para crear variable publicas como comento esta funcionando normal pero hoy esta reportando como que si no existen cuando uso el comando dbUseArea()

Code: Select all | Expand


?op:icons   // en este punto esta visible

NetUse( op:temp+"kardeing",.F.,"tmp" )
Set Filter to tmp->flag != "B"
tmp->(DbGoTop())


aCols := {;
          {"codigo"  ,"Codigo"  ,NIL, 80 ,AL_LEFT},;
          {"op"      ,"Op"      ,NIL, 80 ,AL_LEFT},;
          {"partida" ,"Partida" ,NIL, 80 ,AL_LEFT},;
          {"po"      ,"PO"      ,NIL, 80 ,AL_LEFT},;
          {"estilo"  ,"Estilo"  ,NIL, 80 ,AL_LEFT},;
          {"colores" ,"Colores" ,NIL, 80 ,AL_LEFT},;
          {"talla"   ,"Talla"   ,NIL, 80 ,AL_LEFT},;
          {"cantidad","Cantidad",NIL, 80 ,AL_LEFT};
         }

?op:icons // ya no esta visible

esta es la funcion NetUse

Code: Select all | Expand


   LOCAL lForever

   DEFAULT nSeconds TO NET_SECS

   lForever := ( nSeconds == 0 )

   coun := At( ".",cDatabase )
   If coun>0
      xx:= cDatabase
   Else
      xx:=cDatabase+".dbf"
   EndIf

   If !file(xx)
      MsgStop("base de datos "+cdatabase+" no existe","Error de Apertura")
      DbcloseAll()
      SET RESOURCES TO
      SET 3DLOOK OFF
      CLEAR MEMORY
      Quit
      Return .f.
   EndIf

   DO WHILE ( lForever .OR. ( nSeconds > 0 ) )

      ?op:icons,"user"  // aun esta visible
      If dbUseArea(.T.,,cDatabase,(cAlias),lOpenMode,.F.)
         ?op:icons,"user2"   /// Ya no esta visible
         RETURN ( .T. )
      Else
         ?op:icons,"user4"
      ENDIF
      MsgAlert(OemToAnsi("Archivo "+cFileName(cDataBase)+" bloqueado por otro Usuario"),;
          "Compartir")

      ?op:icons,"user2"
   ENDDO

   ?op:icons,"user3"

[
Alguna idea ???
Last edited by CARLOS ATUNCAR on Sat Mar 01, 2025 11:11 pm, edited 2 times in total.
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
User avatar
CARLOS ATUNCAR
Posts: 195
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru
Been thanked: 2 times
Contact:

Re: Problema con dbUseArea en Fwh2409 y FWH2501.64

Post by CARLOS ATUNCAR »

He probado guardando y restaurando las variables y da este error

Code: Select all | Expand

Application
===========
   Path and name: D:\Proyectos32bits\TallerPro\TallerPro\Bin\TallerPro.Exe (32 bits)
   Size: 4,836,352 bytes
   Compiler version: xHarbour 1.3.1 Intl. (SimpLex) (Build 20241008)
   FiveWin  version: FWH 24.07
   C compiler version: Borland/Embarcadero C++ 7.7 (32-bit)
   Windows 11 64 Bits, version: 6.2, Build 9200 

   Time from start: 0 hours 0 mins 9 secs 
   Error occurred at: 01/03/2025, 11:07:38
   Error description: Error BASE/1004  Class: 'CHARACTER' has no exported method: RESTORE
   Args:
     [   1] = C             
     [   2] = A   {{"CARPETA","D:\Proyectos32bits\TallerPro\TallerPro\Bin\"},{"TEMP","D:\Proyectos32bits\TallerP ... } length: 19

Stack Calls
===========
   Called from:  => RESTORE( 0 )
   Called from: Source\function.prg => NETUSE( 59 )
   Called from: Source\guiaingresos.prg => ADDREG( 238 )
   Called from: Source\guiaingresos.prg => (b)BRWBTNBAR( 137 )
   Called from: .\source\classes\btnbmp.prg => TBTNBMP:CLICK( 816 )
   Called from: .\source\classes\btnbmp.prg => TBTNBMP:LBUTTONUP( 1103 )
   Called from: .\source\classes\control.prg => TCONTROL:HANDLEEVENT( 1867 )
   Called from: .\source\classes\btnbmp.prg => TBTNBMP:HANDLEEVENT( 2143 )
   Called from: .\source\classes\window.prg => _FWH( 1003 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\window.prg => TMDIFRAME:ACTIVATE( 1117 )
   Called from: Source\menu.prg => MAIN( 175 )

System
======
   CPU type: AMD Ryzen 5 5600GT with Radeon Graphics         3593 Mhz
   Hardware memory: 15740 megs

   Free System resources: 90 %
        GDI    resources: 90 %
        User   resources: 90 %

   Windows total applications running: 1
      1 GDI+ Window (AMDRSServ.exe),                                                                                                     

Variables in use
================
   Procedure     Type   Value
   ==========================
   RESTORE
     Param   1:    A    Len:   19
     Local   1:    A    Len:    1
     Local   2:    U    
     Local   3:    U    
   NETUSE
     Param   1:    C    "D:\Proyectos32bits\TallerPro\TallerPro\Bin\temp\kardeing"
     Param   2:    L    .F.
     Param   3:    C    "tmp"
     Local   1:    N    2
     Local   2:    L    .F.
     Local   3:    A    Len:   19

este es el cambio para restaurar

Code: Select all | Expand

   aSave := oP:Save()  // guardamos las variables

   DO WHILE ( lForever .OR. ( nSeconds > 0 ) )


      If dbUseArea(.T.,,cDatabase,(cAlias),lOpenMode,.F.)
         oP:Restore( aSave )
         ?op:icons,"user2"
         RETURN ( .T. )
      Else
         ?op:icons,"user4"
      ENDIF
      MsgAlert(OemToAnsi("Archivo "+cFileName(cDataBase)+" bloqueado por otro Usuario"),;
          "Compartir")

      ?op:icons,"user2"
   ENDDO
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
User avatar
CARLOS ATUNCAR
Posts: 195
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru
Been thanked: 2 times
Contact:

Re: Problema con dbUseArea en Fwh2409 y FWH2501.64

Post by CARLOS ATUNCAR »

he probado crear la variable sin la clase que he venido trabajando mucho tiempo hasta temprano esta es la clase

Code: Select all | Expand

/*  -----------------------------------------------------------------------------
 *  TPublic()
 *  Clase para el reemplazo de Variables Publicas
 *  Version 2.2b - 01/04/2003
 *
 *  Andrade A. Daniel
 *  Rosario - Santa Fe - Argentina
 *
 *  andrade_2knews@hotmail.com
 *  http://www.dbwide.com.ar
 *
 *  Aportes: [ER]   Eduardo Rizzolo
 *           [WA]   Wilson Alves - wolverine@sercomtel.com.br 18/05/2002
 *           [JJMG] Juan J. Mendez Gonzalez
 *
 *  DATAS
 *  -----------------------------------------------------------------------------
 * aVars      - Arreglo de variables
 * cName      - Nombre ultima variable accedida
 * nPos       - Valor ultimo variable accedida
 * lAutomatic - Asignación automatica, por defecto TRUE [WA]
 *
 *  METODOS
 *  -----------------------------------------------------------------------------
 * New()      - Contructor
 * Add()      - Agrega/define nueva variable
 * Del()      - Borra variable
 * Get()      - Accede a una veriable directamente
 * Set()      - Define nuevo valor directamente
 * GetPos()   - Obtener la posición en el array
 * Release()  - Borra todas las variables
 * IsDef()    - Chequea si una variable fue definida
 * Clone()    - Clona la DATA aVars
 * nCount()   - Devuelve cantidad de variables definidas
 * Save()     - Salva DATA aVars
 * Restore()  - Restaura DATA aVars
 *
 *  NOTA
 *  -----------------------------------------------------------------------------
 * Para acceder al valor de una variable, se puede hacer de 2 formas,
 * una directa usando oPub:Get("Codigo") o por Prueba/Error oPub:Codigo,
 * este último es mas simple de usar pero más lento.
 *
 * Para definir un nuevo valor a una variable tambien puede ser por 2 formas,
 * directamente por oPub:Set("Codigo", "ABC" ), o por Prueba/Error
 * oPub:Codigo := "ABC".
 *
 * Atencion: Los metodos Get() y Set() no controlan si la variable existe,
 * para ganar en velocidad.
 *
 * Las variables definidas NO son case sensitive.
 *
 *  MODIFICACIONES Y AGREGADOS
 *  -----------------------------------------------------------------------------
 * 2.2b Correción Bug en metodo Add() sobre FWH.
 * 2.2a Modificado para não restringir o número de variáveis em [x]Harbour [WA]
 * 2.2  Modificada para funcionar en [x]Harbour
 *
 * 2.1  Se guarda el Nombre y Posición de la última variable accedida para incrementar
 *      la velocidad. (Implementado por Eduardo Rizzolo)
 *
 *  EJEMPLO
 *  -----------------------------------------------------------------------------
 * FUNCTION Test()
 * local oP := TPublic():New(), aSave, nPos
 *
 * oP:Add("Codigo")           // Defino variable sin valor inicial
 * oP:Add("Precio", 1.15)     // Defino variable con valor inicial
 * oP:Add("Cantidad", 10 )
 * oP:Add("TOTAL" )
 *
 * // Acceso a variables por prueba/error
 * oP:Total := oP:Precio * oP:Cantidad
 *
 * // Definicion y Acceso a variables directamente
 * oP:Set("Total", oP:Get("precio") * oP:Get("CANTIDAD") )
 *
 * oP:Del("Total")         // Borro una variable
 * ? oP:IsDef("TOTAL")     // Varifico si existe una variable
 *
 * nPos := oP:GetPos("Total") // Obtengo la posición en el array
 * oP:aVars[nPos,2] := 0      // Modifico el Valor en el array directo
 *
 * aSave := oP:Save()      // Guardo las Variables
 * oP:Release()         // Borro TODAS las variables
 * oP:Restore( aSave )     // Restauro las variables
 *
 * oP:End()       // Termino
 *
 * RETURN NIL
 *
 *  EXEMPLO (Asignación Automática)
 *
 * FUNCTION MAIN()
 * LOCAL oP:=TPublic():New(.T.)
 *
 * op:nome     := "Wilson Alves"
 * op:Endereco := "Rua dos Cravos,75"
 * op:Cidade   := "Londrina-PR"
 * op:Celular  := "9112-5495"
 * op:Empresa  := "WCW Software"
 *
 * ? op:Nome,op:Endereco,op:Cidade,op:celular,op:empresa
 *
 * op:End()
 * RETURN NIL
 *
 */

# include "FiveWin.ch"

#ifdef __HARBOUR__
  # xtranslate BYNAME <V> [, <VN> ]     => ::<V> := <V> [; ::<VN> := <VN> ]
  # xtranslate BYNAME <V> DEFAULT <Val> => ::<V> := BYDEFAULT <V>, <Val>
  # xtranslate BYNAME <V> IFNONIL       => if <V> != NIL ; ::<V> := <V> ; endif
  # xtranslate BYDEFAULT <V>, <Val>     => if( <V> == NIL, <Val>, <V> )
#endif

/*
 * TPublic()
 */
CLASS TPublic

   DATA  lAutomatic  AS LOGICAL     INIT .T.    // [WA]

   DATA  aVars       AS ARRAY       INIT NIL
   DATA  nPos        AS NUMERIC     INIT 0   READONLY // [ER]
   DATA  cName       AS CHARACTER   INIT ""  READONLY // [ER]

   METHOD New( lAutomatic )
   METHOD End()      INLINE ::Release()

   METHOD Add( cName, xValue )
   METHOD Del( cName )
   METHOD Get( cName )
   METHOD Set( cName, xValue )

   METHOD GetPos( cName )

   METHOD Release()
   METHOD IsDef( cName )

   METHOD Clone()    INLINE aClone( ::aClone )
   METHOD nCount()      INLINE Len( ::aVars )

   METHOD Save()     INLINE aClone( ::aVars )
   METHOD Restore( aVars ) INLINE ::aVars := aClone( aVars )

#ifdef __HARBOUR__
   ERROR HANDLER OnError( uParam1 )
#else
   ERROR HANDLER OnError( cMsg, nError )
#endif

ENDCLASS

/*
 *  TPublic:New()
 */
METHOD New( lAutomatic ) CLASS TPublic // [WA]

   ::aVars := {}

   BYNAME  lAutomatic DEFAULT .T.   // [WA]

RETURN Self

/*
 *  TPublic:Add()
 */
METHOD Add( cName, xValue ) CLASS TPublic // [ER]

  if cName != NIL
    if (::nPos := aScan( ::aVars, { |e,n| e[1] == AllTrim(Upper(cName)) } )) != 0
      ::aVars[::nPos,2] := xValue

#ifndef __HARBOUR__                 // [WA]
    elseif Len(::aVars) < 4000      // [JJMG]
      aAdd( ::aVars, { AllTrim(Upper(cName)), xValue } )
      ::nPos := Len(::aVars)

    else
      MsgAlert("Demasiadas variables definidas para la Clase TPublic()")

#else
    else
      aAdd( ::aVars, { AllTrim(Upper(cName)), xValue } )
      ::nPos := Len(::aVars)
#endif                              // [WA]

    endif

    ::cName  := cName
  endif

RETURN Self

/*
 *  TPublic:Del()
 */
METHOD Del( cName ) CLASS TPublic
   local nPos

   if cName != NIL
      if (nPos := aScan( ::aVars, { |e,n| e[1] == AllTrim(Upper(cName)) } )) != 0
         aDel( ::aVars, nPos )
         ::aVars := aSize( ::aVars, Len(::aVars) - 1 )

         ::nPos   := 0
         ::cName  := ""
      endif
   endif

RETURN Self

/*
 *  TPublic:Get()
 */
METHOD Get( cName ) CLASS TPublic                  // [by ER]

   if cName != ::cName
      ::nPos   := aScan( ::aVars, { |e,n| e[1] == AllTrim(Upper(cName)) } )
      ::cName  := cName
   endif

RETURN ::aVars[::nPos,2]

/*
 *  TPublic:Set()
 */
METHOD Set( cName, xValue ) CLASS TPublic             // [by ER]

   if cName != ::cName
      ::nPos   := aScan( ::aVars, { |e,n| e[1] == AllTrim(Upper(cName)) } )
      ::cName  := cName
   endif

   ::aVars[::nPos,2] := xValue

RETURN Self

/*
 *  TPublic:GetPos()                         // [by ER]
 */
METHOD GetPos( cName ) CLASS TPublic

   ::cName  := cName

RETURN ::nPos := aScan( ::aVars, { |e,n| e[1] == AllTrim(Upper(cName)) } )


/*
 *  TPublic:Release()
 */
METHOD Release() CLASS TPublic

   ASIZE(::aVars,0)
   ::cName  := ""
   ::nPos   := 0

RETURN Self

/*
 *  TPublic:IsDef()
 */
METHOD IsDef( cName ) CLASS TPublic                // [by ER]

   local lOk := .F.

   if cName != NIL
      if (::nPos := aScan( ::aVars, { |e,n| e[1] == AllTrim(Upper(cName)) } )) != 0
         ::cName := cName
         lOk := .T.
      endif
   endif

RETURN lOk

/*
 *  OnError()
 */
#ifdef __HARBOUR__
   METHOD OnError( uParam1 ) CLASS TPublic
      local cMsg   := __GetMessage()
      local nError := If( SubStr( cMsg, 1, 1 ) == "_", 1005, 1004 )
#else
   METHOD OnError( cMsg, nError ) CLASS TPublic
      local uParam1 := GetParam( 1, 1 )
#endif

   cMsg := Upper( AllTrim( cMsg ))

   if SubStr( cMsg, 1, 1 ) == "_"
      cMsg := SubStr( cMsg, 2 )

      if cMsg == Upper(::cName)
         ::aVars[::nPos,2] := uParam1

      elseif ( ::nPos := aScan( ::aVars, { |e,n| e[1] == cMsg } ) ) != 0
         ::cName  := cMsg
         ::aVars[::nPos,2] := uParam1

      else

         if !::lAutomatic  // [WA]
            _ClsSetError( _GenError( nError, ::ClassName(), cMsg ) )
            ::cName  := ""
            ::nPos   := 0
         else
            ::add(cmsg)
            ::aVars[::nPos,2] := uParam1
         endif
      endif
   else
      if cMsg == Upper(::cName)           // [by ER]
         RETURN ::aVars[::nPos,2]

      elseif ( ::nPos := aScan( ::aVars, { |e,n| e[1] == cMsg } ) ) != 0
         ::cName  := cMsg
         RETURN ::aVars[::nPos,2]
      else
         _ClsSetError( _GenError( nError, ::ClassName(), cMsg ) )
         ::cName  := ""
         ::nPos   := 0
      endif
   endif

RETURN NIL

// Andrade Daniel (2001-2003)
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
User avatar
CARLOS ATUNCAR
Posts: 195
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru
Been thanked: 2 times
Contact:

Re: SavetoDbf() de MariaDb tiene error con dbUseArea()

Post by CARLOS ATUNCAR »

Bueno probe crear la dbf con DbCreate() y se borra el problema la Dbf creada con SavetoDbf() de mariaDb esta probocando algun problema con la funcion DbUseArea() que al parecer resetea las variables de memoria cuando viene sin datos.
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
User avatar
CARLOS ATUNCAR
Posts: 195
Joined: Thu Sep 17, 2015 11:40 pm
Location: Chincha - Peru
Been thanked: 2 times
Contact:

Re: SavetoDbf() de MariaDb tiene error con dbUseArea()

Post by CARLOS ATUNCAR »

bueno encontre el problema era un campo de la tabla con nombre OP que generaba todo este problema
Carlos Atuncar - CaSoftSystem
Chincha - Perú
carlosalbatun@gmail.com
Post Reply