FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with ADO and xBrowse
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Problem with ADO and xBrowse
Posted: Tue Sep 09, 2014 08:42 AM
Hello ,
I have this sample
( FW June 2014 )
=========
Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oCon := TOleAuto():New( "ADODB.Connection" )
   local oRs  := TOleAuto():New( "ADODB.Recordset" )
   local aTables := {}, cTable
   local oError
   Local oDlg,oBrw 
   Local cString := ""
 
   cString := "DRIVER={MySQL ODBC 3.51 Driver};" + ;
                            "server=192.168.0.23" + ;
                            ";database=MastroSQL" +;
                            ";uid=Maurizio" + ;
                            ";pwd=xxxxxx" 

   oCon:Open( cString)  

   oRs:CursorType     = 1        // opendkeyset
   oRs:CursorLocation = 3        // local cache
   oRs:LockType       = 3        // lockoportunistic

      try
         oRs:Open( "SELECT * FROM art_lis WHERE art_lis.corto = 935 " , oCon )
      catch oError
         MsgInfo( oError:Description )
      end   

   DEFINE DIALOG oDlg   FROM 0, 0 TO 400, 400 PIXEL
   
      @ 0,0 XBROWSE oBrw OF oDlg RECORDSET oRs ;
           HEADER  "corto" ,"vend","scon";
           COLUMNS "corto" ,"vend","scon" 
      
        oBrw:aCols[2]:nEditType := EDIT_GET  
        oBrw:aCols[2]:bOnPostedit  := { | o, cVal | Test(oRs,cVal) }
  
       oBrw:CreateFromCode()    
      
   ACTIVATE DIALOG oDlg  CENTER
return nil


Function Test(oRs,cVal)

 oRs:Fields( "scon" ):Value :=  10
 oRs:Fields( "vend" ):Value := cVal 
 
 oRs:Update() 
 
Return nil


When I edit columns 2 ( after 3 o 4 times) I have this error :

Code (fw): Select all Collapse
  Time from start: 0 hours 0 mins 2 secs 
   Error occurred at: 09/09/14, 10:35:36
   Error description: (DOS Error -2147352567) WINOLE/1007  Impossibile individuare la riga specificata per l'aggiornamento. È possibile che alcuni valori siano stati modificati dopo l'ultima operazione di lettura. (0x80040E38): Microsoft Cursor Engine
   Args:
     [   1] = N   0

Stack Calls
===========
   Called from:  => TOLEAUTO:MOVE( 0 )
   Called from: .\source\classes\XBROWSE.PRG => ADOSKIP( 8356 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETADO( 4533 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 442 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SKIP( 0 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1510 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1365 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1699 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 12264 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3279 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 277 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 418 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 23 )
   Called from:  => TOLEAUTO:UPDATE( 0 )
   Called from: accesstest.prg => TEST( 60 )
   Called from: accesstest.prg => (b)MAIN( 47 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:POSTEDIT( 11635 )
   Called from: .\source\classes\XBROWSE.PRG => EDITGETLOSTFOCUS( 11326 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBRWCOLUMN_EDIT( 11216 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:LOSTFOCUS( 2964 )
   Called from: .\source\classes\CONTROL.PRG => (b)TCONTROL( 170 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:LOSTFOCUS( 0 )
   Called from: .\source\classes\TGET.PRG => TGET:LOSTFOCUS( 1216 )
   Called from: .\source\classes\CONTROL.PRG => TGET:KILLFOCUS( 1083 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1696 )
   Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 589 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3279 )
   Called from:  => SYSREFRESH( 0 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:KEYCHAR( 829 )
   Called from: .\source\classes\TGET.PRG => TGET:KEYCHAR( 1117 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1733 )
   Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 589 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3279 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 277 )
   Called from: accesstest.prg => MAIN( 51 )


any help is appreciated

Maurizio
http://www.nipeservice.com
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: Problem with ADO and xBrowse
Posted: Wed Sep 10, 2014 12:24 PM
Hi,

You can try,

Code (fw): Select all Collapse
try
     CursorWait()
        oRs:Update()
        SysRefresh()
     CursorArrow()
 catch oError
     MsgInfo( oError:Description )
end try


Best regards,
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Problem with ADO and xBrowse
Posted: Wed Sep 10, 2014 12:36 PM

Thank But doesn't work :cry:

there are other little errors with ADO and xbrowse

Maurizio

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Problem with ADO and xBrowse
Posted: Thu Oct 09, 2014 03:56 AM
Please remove
oBrw:aCols[2]:bOnPostedit := { | o, cVal | Test(oRs,cVal) }

We recommend not to use bOnPostEdit directly in the application program. XBrowse automatically creates this codeblock. This is reliable and works without errors. Use of bPostEdit is deprecated years back. (Many years back using this codeblock was necessary).

You wanted that once a column is edited, another field is to be changed automatically. This is to be achieved by
oCol:bOnChange := { || oOtherCol:VarPut( <dependantvalue> ) }

Now let me post a revised sample of your code:
Code (fw): Select all Collapse
@ 0,0 XBROWSE oBrw OF oDlg RECORDSET oRs ;
     HEADER  "corto" ,"vend","scon";
     COLUMNS "corto" ,"vend","scon" 
      
WITH OBJECT oBrw:vend
   :nEditType     := EDIT_GET
   :bOnChange     := { || oBrw:scon:VarPut( 10 ) }
END
oBrw:CreateFromCode()

I have been extensively using ADO and there should be no problems with ADO and XBrowse.
Whenever you need, we are here to help you.
Regards



G. N. Rao.

Hyderabad, India
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Problem with ADO and xBrowse
Posted: Tue Oct 14, 2014 09:56 AM

Thanks Rao
your example works .

I have another question :
If I have a select from multiple table and I need to edit a field from the main table I have the same error :

Called from: => TOLEAUTO:MOVE( 0 )
Called from: .\source\classes\XBROWSE.PRG => ADOSKIP( 8356 )

Regards Maurizio

www.nipeservice.com

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Problem with ADO and xBrowse
Posted: Tue Oct 14, 2014 10:37 AM

When we make complex SQL query joining multiple tables not all the columns may be editable.

In such a case, we should first test by modifying a field directly (outside xbrowse) and make sure the value changes and saved without errors.

Can we see a simplified sample of the query?

Regards



G. N. Rao.

Hyderabad, India
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Problem with ADO and xBrowse
Posted: Tue Oct 14, 2014 12:26 PM
This is a sample

Code (fw): Select all Collapse
cSelect := "SELECT    " + ;
               "art_movi.COST,art_movi.QUAN ," + ;
               "arti.DESCRI AS `ArtiDescri`" + ;
               " FROM art_movi "  + ;
               " LEFT  JOIN arti ON art_movi.CORTO = arti.CORTO " 
.
.
.
.

 REDEFINE XBROWSE oBrw RECORDSET oRsMov ID 110 OF oDlg HEADER  "Quantita","Costo"  COLUMNS "Quan","Cost"
   WITH OBJECT oBrw:Quantita
       :nEditType     := EDIT_GET
    END


Thanks Maurizio

Continue the discussion