Problem with ADO and xBrowse

Problem with ADO and xBrowse

Postby Maurizio » Tue Sep 09, 2014 8:42 am

Hello ,
I have this sample
( FW June 2014 )
=========
Code: Select all  Expand view
#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: Select all  Expand view
 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
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Problem with ADO and xBrowse

Postby avista » Wed Sep 10, 2014 12:24 pm

Hi,

You can try,

Code: Select all  Expand view

try
     CursorWait()
        oRs:Update()
        SysRefresh()
     CursorArrow()
 catch oError
     MsgInfo( oError:Description )
end try
 


Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: Problem with ADO and xBrowse

Postby Maurizio » Wed Sep 10, 2014 12:36 pm

Thank But doesn't work :cry:

there are other little errors with ADO and xbrowse

Maurizio
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Problem with ADO and xBrowse

Postby nageswaragunupudi » Thu Oct 09, 2014 3: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: Select all  Expand view
@ 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with ADO and xBrowse

Postby Maurizio » Tue Oct 14, 2014 9: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
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Problem with ADO and xBrowse

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Problem with ADO and xBrowse

Postby Maurizio » Tue Oct 14, 2014 12:26 pm

This is a sample

Code: Select all  Expand view
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
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests