Problem with xBrowse (Fixed)

Problem with xBrowse (Fixed)

Postby Armando » Tue May 16, 2023 4:39 am

Mr. Rao:

I need your help again

Please watch this video, if you need more information just tell me

Image

As we can see, after adding two records to the recordset we exit and when we reopen the program we get an error

Regards
Last edited by Armando on Tue Jun 06, 2023 4:39 pm, edited 2 times in total.
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby nageswaragunupudi » Tue May 16, 2023 4:48 pm

To be honest, I could not understand.
Can you please copy the error.log here please?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with xBrowse

Postby Armando » Tue May 16, 2023 5:00 pm

Mr. Rao:

First, thank you for yor interest, here is the error log file.

If you prefer, give me an email address to send you a self-contained program

Application
===========
Path and name: C:\TestXbrw\TestXBrw.Exe (32 bits)
Size: 4,218,368 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 20.12
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 8 secs
Error occurred at: 16/05/2023, 10:55:20
Error description: (DOS Error -2147352567) WINOLE/1007 El identificador de fila se refirió a una fila eliminada o a una fila marcada para eliminar. (0x80040E23): Microsoft Cursor Engine

Stack Calls
===========
Called from: => TOLEAUTO:VALUE( 0 )
Called from: .\source\function\ADOFUNCS.PRG => FWADOFIELDSTRUCT( 2069 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SETCOLFROMADO( 7106 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SETADO( 6577 )
Called from: .\source\classes\XBROWSE.PRG => XBRWSETDATASOURCE( 17313 )
Called from: .\source\classes\XBROWSE.PRG => XBROWSENEW( 17095 )
Called from: Source\Test.Prg => TEST( 49 )
Called from: Source\TestXbrw.Prg => (b)LABARRA( 124 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 713 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 999 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1817 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2051 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1097 )
Called from: Source\TestXbrw.Prg => MAIN( 95 )

System
======
CPU type: AMD Ryzen 5 5500U with Radeon Graphics 2096 Mhz
Hardware memory: 15755 megs

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

Windows total applications running: 5
1 ,
2 , C:\TestXbrw\TestXBrw.Exe
3 , C:\WINDOWS\System32\shcore.dll
4 , C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.1635_none_6ebca7
5 GDI+ Window (AsusOSD.exe), C:\WINDOWS\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.22621.1635_none_9fa79a41e294b9

Variables in use
================
Procedure Type Value
==========================
TOLEAUTO:VALUE
Param 1: O Class: ERROR
FWADOFIELDSTRUCT
Local 1: U
Local 2: U
TXBROWSE:SETCOLFROMADO
Param 1: O Class: TOLEAUTO
Param 2: O Class: TOLEAUTO
Local 1: U
Local 2: U
Local 3: O Class: TOLEAUTO
Local 4: N 133
Local 5: U
Local 6: C "D"
Local 7: N 8
Local 8: N 0
Local 9: L .T.
Local 10: S
Local 11: U
TXBROWSE:SETADO
Param 1: C "HDR_FDM"
Param 2: L .T.
Param 3: A Len: 12
Param 4: L .F.
Param 5: C "MYSQL"
Local 1: O Class: TXBROWSE
Local 2: A Len: 2
Local 3: N 133
Local 4: U
Local 5: U
Local 6: U
Local 7: O Class: TXBRWCOLUMN
Local 8: O Class: TOLEAUTO
Local 9: U
Local 10: U
Local 11: U
Local 12: B {|| ... }
XBRWSETDATASOURCE
Param 1: O Class: TOLEAUTO
Param 2: L .T.
Param 3: L .T.
Param 4: A Len: 10
Local 1: O Class: TXBROWSE
Local 2: C "MYSQL"
Local 3: N 10
Local 4: N 2
Local 5: O Class: TXBRWCOLUMN
Local 6: A Len: 12
Local 7: L .F.
XBROWSENEW
Param 1: O Class: TXBROWSE
Param 2: O Class: TOLEAUTO
Param 3: L .T.
Param 4: L .T.
Param 5: A Len: 10
Param 6: U
Param 7: A Len: 10
Param 8: U
Local 1: C "O"
Local 2: U
Local 3: L .F.
TEST
Param 1: O Class: TDIALOG
Param 2: N 0
Param 3: N 0
Param 4: U
Param 5: U
Param 6: U
Param 7: A Len: 10
Param 8: A Len: 10
Param 9: U
Param 10: U
Param 11: U
Param 12: U
Param 13: U
Param 14: U
Param 15: U
Param 16: U
Param 17: L .F.
Param 18: O Class: TOLEAUTO
Param 19: U
Param 20: L .F.
Param 21: U
Param 22: L .F.
Param 23: N 200
Param 24: L .T.
Param 25: L .F.
Param 26: A Len: 10
Param 27: A Len: 6
Param 28: A Len: 10
Param 29: U
Param 30: L .T.
Param 31: L .F.
Param 32: L .F.
Param 33: L .F.
Param 34: U
Param 35: U
Param 36: U
Param 37: U
Param 38: L .F.
Param 39: L .F.
Param 40: C "oBrw"
Param 41: U
Local 1: O Class: TXBROWSE
Local 2: U
Local 3: U
Local 4: U
Local 5: U
(b)LABARRA
Param 1: O Class: TMDIFRAME
Local 1: O Class: TDIALOG
Local 2: U
Local 3: O Class: TFONT
TBTNBMP:CLICK
Param 1: O Class: TBTNBMP
TBTNBMP:LBUTTONUP
TCONTROL:HANDLEEVENT
Param 1: N 26
Param 2: N 27
Param 3: N 0
Local 1: L .T.
Local 2: N 0
Local 3: S
TBTNBMP:HANDLEEVENT
Param 1: N 514
Param 2: N 0
Param 3: N 1703963
Local 1: U
_FWH
Param 1: N 514
Param 2: N 0
Param 3: N 1703963
WINRUN
Param 1: N 1703963
Param 2: N 514
Param 3: N 0
Param 4: N 1703963
Param 5: N 5
Local 1: O Class: TBTNBMP
TMDIFRAME:ACTIVATE
Param 1: N 461008
MAIN
Param 1: C "MAXIMIZED"
Param 2: U
Param 3: U
Param 4: U
Param 5: U
Param 6: B {|| ... }
Param 7: U
Param 8: B {|| ... }
Param 9: U
Param 10: U
Param 11: U
Param 12: U
Param 13: U
Param 14: U
Param 15: U
Param 16: U
Param 17: B {|| ... }
Param 18: U
Param 19: U
Param 20: L .F.
Local 1: O Class: TMDIFRAME
Local 2: U
Local 3: U

Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFNTX

DataBases in use
================

Classes in use:
===============
1 ERROR
2 HBCLASS
3 HBOBJECT
4 TWINDOW
5 TCONTROL
6 TGET
7 TAPLICACION
8 TINI
9 WIN_OLEAUTO
10 TOLEAUTO
11 TICON
12 TBRUSH
13 TMDIFRAME
14 TMENU
15 TREG32
16 TMENUITEM
17 TMDICLIENT
18 TFONT
19 TMSGBAR
20 TRECT
21 TMSGITEM
22 TTIMER
23 TBITMAP
24 TIMAGE
25 TCURSOR
26 TBAR
27 TBTNBMP
28 TMDICHILD
29 TDIALOG
30 TXBROWSE
31 TXBRWCOLUMN
32 TSCROLLBAR
33 TCLIPBOARD
34 TSTRUCT

Memory Analysis
===============
598 Static variables

Dynamic memory consume:
Actual Value: 2031616 bytes
Highest Value: 2031616 bytes

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby karinha » Tue May 16, 2023 8:33 pm

Buenas Armando, código?

Called from: Source\Test.Prg => TEST( 49 )
Called from: Source\TestXbrw.Prg => (b)LABARRA( 124 ) bad linea.

??

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7794
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problem with xBrowse

Postby Armando » Wed May 17, 2023 1:04 am

Joao:
Here is the main.Prg code
Code: Select all  Expand view

#include "FiveWin.Ch"
#include "Ado.ch"
#include "FileIO.ch"

#define cBorde      NOBORDER
#define nIcono      1

STATIC oWindow
STATIC oError
STATIC aVars := {NIL,NIL,NIL}


#xtranslate aBtns = > aVars\[ 1\]
#xtranslate aMenu = > aVars\[ 2\]
#xtranslate aSubM = > aVars\[ 3\]

MEMVAR oApp

// Para que los acentos se vean bien
REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESWIN

FUNCTION Main()
   LOCAL oIcono, oCursor, oCasilla, oBmp , oBrush

   LOCAL lStatus := ( .T. )

   LOCAL hWnd

   SET CENTURY ON
   SET DATE TO FRENCH
   SET DELETED ON
   SET OPTIMIZE ON
   SETBALLOON(.T.)

   HB_CDPSELECT("ESWIN")
   HB_LangSelect( "ESWIN" )

   FWSetLanguage( 2 )      // Para poner el PREVIEW en Español


// Para que los acentos se vean bien
   SET( _SET_CODEPAGE, "ESWIN" )

   SETHELPFILE( "ParCre.Hlp" )

// Para cambiar el color del get con foco
   TGet():lClrFocus := (.T.)
   TGet():nClrFocus := nRGB( 213, 219, 255 )   // Lila claro

   oApp := TAplicacion()

   LeeIni()               // Lee parametros

    hWnd := FindWindow( 0, oApp:cAplicacion + " " + oApp:cVersion + " " + oApp:cServer)

   IF hWnd != 0 .AND. ! oApp:lInstancia
      ShowWindow( hWnd, 3) //SW_MAXIMIZE=3 SW_NORMAL=1 SW_MINIMIZE=6
      QUIT
   ENDIF

   IF ! Conecta()
      QUIT
   ENDIF

   aBtns := ARRAY(05)

   aMenu := ARRAY(10)
   aSubM := ARRAY(05)

//   LeeEmpresa( )

   DEFINE ICON oIcono RESOURCE "AppLogo"
   DEFINE BRUSH oBrush COLOR CLR_WHITE
    DEFINE WINDOW oWindow MDI FROM 0, 0 TO 22, 75 TITLE oApp:cAplicacion + " " + oApp:cVersion + " " + oApp:cServer;
      MENU HazMenu() ICON oIcono BRUSH oBrush PIXEL MENUINFO 8

   SET MESSAGE OF oWindow TO oApp:cRazonSocial KEYBOARD CLOCK 2007

   IF ! EMPTY( oApp:cUsuario )
      DEFINE MSGITEM oCasilla OF oWindow:oMsgBar   SIZE 120 ;
      PROMPT ALLTRIM( oApp:cUsuario ) COLOR CLR_BLACK, CLR_BLUE
   ENDIF

   DEFINE MSGITEM oCasilla OF oWindow:oMsgBar ;
   SIZE 85 ;
      PROMPT Date2Txt( DATE( ) )

   DEFINE MSGITEM oCasilla OF oWindow:oMsgBar ;
   SIZE 175 ;
   PROMPT oApp:cCopyRight

   oBmp = TImage():Define(,cFilePath(GetModuleFileName(GetInstance())) + "AppFondo.Jpg")
      oWindow:bPainted := {|hDC| PalBmpDraw( hDC, 0, 0,oBmp:hBitmap,, oWindow:nWidth, oWindow:nHeight,, (.T.)) }

   ACTIVATE WINDOW oWindow MAXIMIZED VALID Salir() ON INIT (LaBarra(oWindow), oWindow:Refresh())

   oIcono:End()
   oCasilla:End()
   oBmp:End()
   oBrush:End()
RETURN(.T.)

/*
* ---------------------------------------------------------------------------- *
*/

STATIC FUNCTION LaBarra( oWindow )
   LOCAL oBarra
   LOCAL oCursor

   DEFINE CURSOR oCursor RESOURCE "Dedo"
   DEFINE BUTTONBAR oBarra SIZE 45, 45 OF oWindow CURSOR oCursor 2007

      oBarra:bClrGrad = { | lInvert | If( ! lInvert,;
         { { 0.25, nRGB( 068, 097, 176 ), nRGB( 068, 097, 176 ) },;
         {   0.75, nRGB( 068, 097, 176 ), nRGB( 068, 097, 176 ) } },;
         { { 0.25, nRGB( 255, 255, 255 ), nRGB( 255, 255, 255 ) },;
         {   0.75, nRGB( 255, 255, 255 ), nRGB( 255, 255, 255 ) } } ) }

      oBarra:nClrText = { | lInvert | IF( ! lInvert, nRGB( 235, 160, 86 ), nRGB( 20, 20, 20 ) ) }

   * ------------------------------------------------------------------------- *

   DEFINE BUTTON aBtns[01] OF oBarra RESOURCE "Brw32" cBorde ;
      ACTION Test(oWindow )
   aBtns[01] :cToolTip := { "Test", "Test button", nIcono, oApp:cClrForTol, oApp:cClrBakTol }

   DEFINE BUTTON aBtns[02] OF oBarra RESOURCE "Exi32" cBorde ;
      GROUP ;
      ACTION oWindow:END( ) ;
      MESSAGE "Abandona el programa y retorna a windows"
   aBtns[02] :cToolTip := { "Salir", "Exit button", nIcono, oApp:cClrForTol, oApp:cClrBakTol }
RETURN (.T.)

/*
* ---------------------------------------------------------------------------- *
*/

STATIC FUNCTION HazMenu( )
    LOCAL oMenu

    MENU oMenu 2007
        MENUITEM aMenu[01] PROMPT "&Test xBrowse"
            MENU
            MENUITEM aSubM[01] PROMPT "&Test";
               RESOURCE "Brw16" ;
               ACTION Test(oWindow )
            SEPARATOR
            MENUITEM aSubM[02] PROMPT "Salir  ALT-F4" ;
               RESOURCE "Exi16" ;
               ACTION oWindow:END( )
         ENDMENU
   ENDMENU
RETURN(oMenu)


/*
* ---------------------------------------------------------------------------- *
*/

STATIC FUNCTION Salir( )
   IF MsgNoYes( "Seguro desea salir de la aplicación ?", oApp:cAplicacion )
        oApp:oCon:Close()
   ELSE
      RETURN ( .F. )
   ENDIF
RETURN ( .T. )


/*
* ---------------------------------------------------------------------------- *
*/

STATIC FUNCTION LeeEmpresa( )
   LOCAL oRsEmp, oError

   oRsEmp := FW_OpenRecordSet(oApp:oCon,"SELECT " +;
                                          "* " +;
                                       "FROM " +;
                                          "Empresa",adLockOptimistic,adOpenDynamic,0)

   IF oRsEmp == nil
        MsgStop("No pude abrir la tabla EMPRESA !",oApp:cAplicacion)
      FW_ShowAdoError(oApp:oCon)
      RETURN(.F.)
   ENDIF

   IF oRsEmp:BOF( ) .AND. oRsEmp:EOF( )
      oApp:cRazonSocial := "Empresa no registrada, s.a. de c.v."
   ELSE
      oApp:cRazonSocial := oRsEmp:Fields( "EMP_NOM" ) :Value
   ENDIF

   IF oRsEmp <> NIL
      IF oRsEmp:State( ) = adStateOpen
         oRsEmp:Close( )
      ENDIF
   ENDIF
RETURN( .T. )

/*
* ---------------------------------------------------------------------------- *
*/

FUNCTION Alinea( oReporte, Izq, Der, lTitle )
   DEFAULT lTitle   := ( .T. )

   IF lTitle
      oReporte:oTitle:aRow[ Izq ] := oReporte:oTitle:aRow[ Der ]
   ELSE
      oReporte:oHeader:aRow[ Izq ] := oReporte:oHeader:aRow[ Der ]
   ENDIF
RETURN ( NIL )


/*
* ---------------------------------------------------------------------------- *
*/

FUNCTION OverFlow( oReporte )
   IF ( oReporte:nRow + ( oReporte:nStdLineHeight * 2 ) ) >= oReporte:nBottomRow
      oReporte:EndPage( )
      oReporte:StartPage( )
   ENDIF
RETURN NIL


/*
* ---------------------------------------------------------------------------- *
*/

CLASS TAplicacion
   DATA cUsuario        INIT ""
   DATA cRazonSocial    INIT "EMPRESA NO REGISTRADA, S.A. DE C.V."
   DATA cAplicacion     INIT "© " + STR( YEAR( DATE( ) ), 4, 0 ) + " XBrowse Test"// + SPACE(2) + FWVERSION
   DATA cAppAlias       INIT "© " + STR( YEAR( DATE( ) ), 4, 0 ) + " ParCre"
   DATA cCopyRight      INIT "© 2021-" + STR( YEAR( DATE( ) ), 4, 0 ) + " by S.O.I., s.a. de c.v."
   DATA cVersion        INIT "Versión 1.0M18"
   DATA nLineStyle      INIT 4

   DATA cPath           INIT ""
   DATA cPathExe        INIT cFilePath(GetModuleFileName(GetInstance()))                    // C:\ParCre\
   DATA cCrypt          INIT "XrypT2023"

   // Estos parámetros son para el servidor de MySql
   DATA oCon            INIT NIL
   DATA oDsn            INIT NIL
   DATA cDsn            INIT NIL
   DATA cDescription    INIT NIL
   DATA cServer         INIT NIL
   DATA cDBName            INIT NIL
   DATA cDataBase       INIT NIL
   DATA cUser           INIT NIL
   DATA cPass           INIT NIL
   DATA nPort           INIT NIL
   DATA cStmt           INIT ""
   DATA cDriveName      INIT ""

   DATA nRowsInt        INIT 3

    // Colores del dialogo
   DATA cBrush          INIT "Brush"

   // Colores de la pijama
   DATA nRowNonClr      INIT RGB( 255, 255, 255 )
   DATA nRowParClr      INIT RGB( 238, 246, 255 )

   // Colores para encabezados del browse
   DATA nHdrForClr      INIT RGB( 255, 255, 255 ) // Blanco
   DATA nHdrBckClr      INIT RGB( 000, 000, 000 ) // Negro

   DATA nFClrFocus      INIT RGB( 000, 000, 000 ) // Negro
   DATA nBClrFocus      INIT RGB( 000, 191, 255 ) // Azúl, se ve bien

   DATA cClrForTol      INIT CLR_WHITE
   DATA cClrBakTol      INIT CLR_HBLUE
ENDCLASS


/*
* ------------------------------------------------------------------------ *
* ------------------------------------------------------------------------ *
*/

STATIC FUNCTION LeeIni()
    LOCAL oIni

    INI oIni FILE ".\ParCre.Ini"
        GET oApp:cDsn              SECTION "MYSQL"     ENTRY "Dsn"             OF oIni DEFAULT "TestXbrw"
      GET oApp:cDescription   SECTION "MYSQL"      ENTRY "Description"  OF oIni DEFAULT "XBrowse Test"
      GET oApp:cServer        SECTION "MYSQL"      ENTRY "Server"       OF oIni DEFAULT "localhost"
      GET oApp:cDataBase      SECTION "MYSQL"      ENTRY "DataBase"     OF oIni DEFAULT ""
      GET oApp:cUser          SECTION "MYSQL"      ENTRY "User"         OF oIni DEFAULT "root"
      GET oApp:cPass          SECTION "MYSQL"      ENTRY "PassWord"     OF oIni DEFAULT "91502127"
      GET oApp:nPort          SECTION "MYSQL"      ENTRY "Port"         OF oIni DEFAULT 3306
      GET oApp:cDriveName     SECTION "MYSQL"      ENTRY "DriveName"    OF oIni DEFAULT "Driver={MySQL ODBC 5.1 Driver}"
      GET oApp:cPath          SECTION "MYSQL"      ENTRY "Path"         OF oIni DEFAULT "C:\Program Files\MySQL\MySQL Server 5.1\bin\"
      GET oApp:cStmt          SECTION "
MYSQL"      ENTRY "Statement"    OF oIni DEFAULT ""
      GET oApp:cDBName        SECTION "
DATABASE"   ENTRY "DBName"       OF oIni DEFAULT "TestXBrw"
   ENDINI
RETURN( NIL )


/*
* ---------------------------------------------------------------------------- *
*/
STATIC FUNCTION Conecta( )
   LOCAL oError

   TRY
    oApp:oCon := TOleAuto( ) :new( "
adodb.connection" )
   CATCH oError
   MsgStop( "
No se ha podido crear la conexión al servidor !", oApp:cAplicacion )
   RETURN( .F. )
   END

   oApp:oCon:ConnectionString := ALLTRIM( oApp:cDriveName ) + ;
      "
;Server=" + ALLTRIM( oApp:cServer ) + ;
      "
;Port=" + STR( oApp:nPort ) + ;
      "
;Database=" + ALLTRIM( oApp:cDataBase ) + ;
      "
;User=" + ALLTRIM( oApp:cUser ) + ;
      "
;Password=" + ALLTRIM( oApp:cPass ) + ;
      "
;Option=3;"


   oApp:oCon:CommandTimeout      := 1800     // 30 Minutos * 60 segundos
   oApp:oCon:ConnectionTimeout   := 28800    //  8 horas * 360 segundos

   TRY
      oApp:oCon:Open()
      oApp:oCon:Execute( "
SET SESSION wait_timeout = 86400;" )
   CATCH oError
      MsgInfo( "
No se pudo lograr la conexión al servidor, REVISE LA CONEXION DE SU RED O LA CONEXION A INTERNET !" + CRLF +;
               oApp:oCon:ConnectionString, oApp:cAplicacion )
      FW_ShowAdoError(oApp:oCon)
      RETURN( .F. )
   END
RETURN( .T. )



And. here is the Test.Prg code, this creates the HDRVDA table in Test Database and add two records,
So far so good, the recrods are displayed in the main browser, but when you exit Test.Prg and re-enter it throws the error.
We can see the problem in the video above


Code: Select all  Expand view

#Include "FiveWin.ch"
#Include "Ado.ch"
#Include "xbrowse.ch"

MEMVAR oApp

STATIC oWnd
STATIC oRsHdr

STATIC oBtns

FUNCTION Test(oWindow)
   LOCAL oDlg,oBrw,oFont

    oBtns       := ARRAY(05)

   CreateDB()
   OpenTable()

    DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0,-10
    DEFINE ICON oIcono RESOURCE "AppLogo"
    DEFINE WINDOW oWnd MDICHILD OF oWindow FROM 0,0 TO 10,10;
        TITLE "Relación de movimientos de almacén" ICON oIcono

        oWnd:bGotFocus  = { || oBrw:SetFocus() }

        DEFINE DIALOG oDlg RESOURCE "BrwVda" OF oWnd FONT oFont ICON oIcono

         REDEFINE BUTTONBAR oBar ID 100 OF oDlg SIZE 56,42 2007

            DEFINE BUTTON oBtns[01] OF oBar ;
               RESOURCE "Add16" TOP NOBORDER;
               PROMPT "&Agregar";
               ACTION InsertMovs(oBrw)

            DEFINE BUTTON oBtns[04] OF oBar ;
               ACTION oWnd:End();
               RESOURCE "Exi16" TOP NOBORDER;
               PROMPT "&Salir";
               GROUP

            REDEFINE XBROWSE oBrw ID 200 OF oDlg;
                DATASOURCE oRsHdr;
            COLUMNS "HDR_FOL","HDR_FDM","HDR_REF","","","","","","SUC_NOM","HDR_CAN";
                HEADERS "Folio","Fecha","Referencia","Tipo","Unidades","Costos","Unidades","Costos","Sucursal","Can";
                COLSIZES 50,80,80,60,70,75,70,75,110,32;
                PICTURES "@Z 9999999","dd/mmm/yyyy",Nil,Nil,"@Z 9,999,999","@Z 99,999,999.99","@Z 9,999,999","@Z 99,999,999.99",Nil,Nil;
                JUSTIFY {AL_RIGHT,AL_RIGHT,AL_LEFT,AL_LEFT,AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_LEFT,AL_CENTER};
                FOOTERS AUTOSORT //BACKGROUND oApp:cBrush

                WITH OBJECT oBrw
                    :l2007            := (.F.)
                    :lHScroll         := (.F.)
                    :lVScroll         := (.F.)
                    :nMarqueeStyle    := MARQSTYLE_HIGHLROW
                    :nColDividerStyle := LINESTYLE_LIGHTGRAY
                    :nRowDividerStyle := LINESTYLE_LIGHTGRAY
               :SetGroupHeader( "E N T R A D A S",05,06 )
               :SetGroupHeader( "S A L I D A S",07,08 )
                    :nHeaderHeight      := 25
                    :nRowHeight         := 22
                    :nFooterHeight      := 25
                    :bClrHeader       := { || {CLR_WHITE,CLR_BLACK} }
                    :bClrFooter       := { || {CLR_WHITE,CLR_BLACK} }
                    :bClrSel          := { || IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
                    :bClrSelFocus     := { || {oApp:nFClrFocus,oApp:nBClrFocus} }
                    :bClrStd          := { || IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
                    :nRecSelColor     := oApp:nRowParClr
                    :lDisplayZeros    := (.F.)

                    WITH OBJECT :Folio
                        :cOrder := "A"
                    END

                    WITH OBJECT :Tipo
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                                oRsHdr:Fields("HDR_EOS"):Value == 1,;
                                                                "Entrada","Salida")}
                        :nHeadStrAlign  := AL_LEFT
               END

                    WITH OBJECT :aCols[05]
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                                oRsHdr:Fields("HDR_EOS"):Value == 1,;
                                                                Transform(oRsHdr:Fields("HDR_TOU"):Value,"@Z 9,999,999"),"")}
                        :nHeadStrAlign  := AL_RIGHT
                    END

                    WITH OBJECT :aCols[06]
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                                oRsHdr:Fields("HDR_EOS"):Value == 1,;
                                                                Transform(oRsHdr:Fields("HDR_TOC"):Value,"@Z 99,999,999.99") ,"")}
                        :nHeadStrAlign  := AL_RIGHT
                    END

                    WITH OBJECT :aCols[07]
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                                oRsHdr:Fields("HDR_EOS"):Value == 2,;
                                                                Transform(oRsHdr:Fields("HDR_TOU"):Value,"@Z 9,999,999"),"")}
                        :nHeadStrAlign  := AL_RIGHT
                    END

                    WITH OBJECT :aCols[08]
                        :bStrData           := { || IF(oRsHdr:RecordCount() > 0 .AND.;
                                                                oRsHdr:Fields("HDR_EOS"):Value == 2,;
                                                                Transform(oRsHdr:Fields("HDR_TOC"):Value,"@Z 99,999,999.99") ,"")}
                        :nHeadStrAlign  := AL_RIGHT
                    END

                    WITH OBJECT :aCols[10]
                      :SetLogical()
                    :SetCheck(NIL,(.T.))
                    END
                END

        ACTIVATE DIALOG oDlg NOWAIT ON INIT oDlg:MOVE(0,0) VALID ! GetASyncKey(VK_ESCAPE)
    ACTIVATE WINDOW oWnd ON INIT (oWnd:SETSIZE(oDlg:nWidth+15,oDlg:nHeight+29),oBrw:SetFocus) VALID CloseTable()

    oFont:END()
    oIcono:END()
RETURN(.T.)


* ---------------------------------------------------------------------------- *
STATIC FUNCTION CreateDB()
   LOCAL cCmdSql           := NIL

   oApp:oCon:Execute("USE Test")

   cCmdSql := "CREATE TABLE IF NOT EXISTS HdrVda (" +;
                  "HDR_FOL INTEGER(03)  NOT NULL    AUTO_INCREMENT    COMMENT 'Folio'," +;
                  "HDR_EOS DECIMAL(01,0)  NOT NULL DEFAULT 0            COMMENT 'E=Entrada y S=Salida'," +;
                  "HDR_SUC DECIMAL(03,0)      NULL                      COMMENT 'Número de sucursal'," +;
                  "HDR_FDM DATE           NOT NULL DEFAULT '0000-00-00' COMMENT 'Fecha del movimiento'," +;
                  "HDR_REF VARCHAR(15)    NOT NULL DEFAULT ''           COMMENT 'Referencia'," +;
                  "HDR_TOU DECIMAL(05,0)  NOT NULL DEFAULT 0            COMMENT 'Total de unidades'," +;
                  "HDR_TOC DECIMAL(11,2)  NOT NULL DEFAULT 0.00         COMMENT 'Total de costos'," +;
                  "HDR_CAN BIT            NOT NULL DEFAULT 0            COMMENT 'Cancelado ?'," +;
                  "HDR_MOT VARCHAR(50)    NOT NULL DEFAULT ''           COMMENT 'Motivo de la cancelación'," +;
                  "PRIMARY KEY(HDR_FOL))" +;
                  "ENGINE = InnoDB                                      COMMENT 'Encabezado de vales de almacén';"

   oApp:oCon:Execute(cCmdSql)

RETURN(.T.)

* ---------------------------------------------------------------------------- *
STATIC FUNCTION OpenTable()
   oRsHdr := FW_OpenRecordSet(oApp:oCon,"SELECT " +;
                                          "*," +;
                                          "SUC_NOM " +;
                                       "FROM " +;
                                          "HdrVda " +;
                                       "LEFT JOIN " +;
                                          "Sucursales " +;
                                       "ON " +;
                                          "HDR_SUC = Sucursales.SUC_NUM",adLockOptimistic,adOpenDynamic,0)

   IF oRsHdr == nil
        MsgStop("I can't open the table HDRVDA !",oApp:cAplicacion)
        FW_ShowAdoError(oApp:oCon)
      RETURN(.F.)
   ENDIF

    IF oRsHdr:BOF() .AND. oRsHdr:EOF()
    ELSE
      oRsHdr:MoveFirst()
    ENDIF
RETURN(.T.)

* ---------------------------------------------------------------------------- *
STATIC FUNCTION InsertMovs(oBrw)
   oRsHdr:AddNew()
   oRsHdr:Fields("HDR_EOS"):Value   := 1           // In
   oRsHdr:Fields("HDR_SUC"):Value   := AdoNull()   // Only out movs has value
   oRsHdr:Fields("HDR_FDM"):Value   := Date()
   oRsHdr:Fields("HDR_TOU"):Value   := 10
   oRsHdr:Fields("HDR_TOC"):Value   := 175.25
   oRsHdr:UpDate()

   oRsHdr:AddNew()
   oRsHdr:Fields("HDR_EOS"):Value   := 2           // Out
   oRsHdr:Fields("HDR_SUC"):Value   := 1           // Only out movs has value
   oRsHdr:Fields("HDR_FDM"):Value   := Date()
   oRsHdr:Fields("HDR_REF"):Value   := "F-254"
   oRsHdr:Fields("HDR_TOU"):Value   := 150
   oRsHdr:Fields("HDR_TOC"):Value   := 15000.00
   oRsHdr:UpDate()

   oRsHdr:ReQuery()

   oBrw:Refresh()
   oBrw:SetFocus()
RETURN(.T.)


* ---------------------------------------------------------------------------- *
*/
STATIC FUNCTION CloseTable()
    oWnd        := NIL

    IF oRsHdr <> NIL
        IF oRsHdr:State() = adStateOpen
            oRsHdr:Close()
        ENDIF
    ENDIF
RETURN(.T.)
 


Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby nageswaragunupudi » Wed May 17, 2023 12:55 pm

Just before the definition of xbrowse, please ensure that the oRs is open and not empty and set oRs:MoveFirst().
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with xBrowse

Postby Armando » Wed May 17, 2023 3:44 pm

Mr. Rao:

I have reviewed the code and before defining the browse there are two functions

CreateDB()
OpenTable()
.......
.......
Here I define the Browse

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby Armando » Thu May 18, 2023 8:36 pm

Mr Rao:

Any clue?

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby Armando » Wed May 24, 2023 4:09 pm

Mr. Rao:

There is no time to help us?

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby nageswaragunupudi » Sun May 28, 2023 1:59 am

This is the error you got:
Code: Select all  Expand view

Error description: (DOS Error -2147352567) WINOLE/1007 El identificador de fila se refirió a una fila eliminada o a una fila marcada para eliminar. (0x80040E23): Microsoft Cursor Engine

Stack Calls
===========
Called from: => TOLEAUTO:VALUE( 0 )
 

English Translation:
Code: Select all  Expand view

Error description: (DOS Error -2147352567) WINOLE/1007 The row identifier referred to a deleted row or a row marked for deletion. (0x80040E23): Microsoft Cursor Engine
 


This kind of error arises in cases like this:
Code: Select all  Expand view

   local oCn, oRs, oField

   oCn   := FW_MSSQLDB()
   oRs   := FW_OpenRecordSet( oCn, "states" )
   oRs:Delete()
   oField   := oRs:Fields( 0 )
   ? oField:Value // error 1007
 

This is the error:
Code: Select all  Expand view

   Error description: (DOS Error -2147352567) WINOLE/1007  Row handle referred to a deleted row or a row marked for deletion. (0x80040E23): Microsoft Cursor Engine

Stack Calls
===========
   Called from:  => TOLEAUTO:VALUE( 0 )
 


1007 group of errors occur when accessing a recordset is closed or eof/bof is true or record is deleted.
Please check if any situation exists
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with xBrowse

Postby Armando » Sun May 28, 2023 2:37 am

Mr. Rao:

Thank you for you help.

I have checked and there is no situation like the one you mention, in fact there is no DELETE code

Above you can see all the code and all the error.log file.

the first time I enter with the empty table, the two records are added
, one input and the next output, and they are displayed in the browse without problem.

When leaving and returning to continue increasing more records, the browse throws the problem

More data, I am simulating movements in a warehouse, inputs and outputs, at the outputs
You must fill in the HDR_SUC field that contains the number of the destination branch, it is not the
In the case of entries, there is no destination branch, for this reason the field is Null

The funny thing is that just reversing the order in which the records are written, output first and
after input, everything works fine.

Also, if I remove the LEFT JOIN everything works fine.

I hope you can help me, I'm going crazy

Best regards, thank you again
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby nageswaragunupudi » Sun May 28, 2023 3:48 am

oApp:oCon:Execute("USE Test")

What does this do?
Forgive my ignorance.
Is there a MySql command like "USE test"?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with xBrowse

Postby Armando » Sun May 28, 2023 3:57 am

Mr. Rao:

Yes, USE is a mysql command, after this command all commands affect tables in TEST database

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Problem with xBrowse

Postby nageswaragunupudi » Sun May 28, 2023 4:24 am

Armando wrote:Mr. Rao:

Yes, USE is a mysql command, after this command all commands affect tables in TEST database

Best regards

Oh Sorry, yes. Pardon my forgetfulness.
It selects TEST as current database.

I am now copying your program with minor changes and trying to execute at my end.

BTW, it is now about 10:30 pm in Toluca. Are you still awake?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with xBrowse

Postby Armando » Sun May 28, 2023 4:35 pm

Mr. Rao:

Oh Sorry, yes. Pardon my forgetfulness.
It selects TEST as current database.

Don't worry!

I am now copying your program with minor changes and trying to execute at my end.

Thanks a lot

BTW, it is now about 10:30 pm in Toluca. Are you still awake?


Yeah I'm up for a couple more hours, got a lot of work

With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 36 guests