Mysql ADO and TDataRow

Mysql ADO and TDataRow

Postby Maurizio » Tue Jun 27, 2017 4:41 pm

Hello Rao ,

I have a table with a field AUTO_INCREMENT ( Es. NUMBER ) , sometimes I need to replace a value in NUMBER ( which doesn't exist ) .

If I do it with ADO command it works
Es: oRs:Fields( "NUMBER" ):Value := 15

but if I do with TdataRow I have a error .
Es:
oRec:NUMBER := 15
oRec:Save()

I think that the problem is in METHOD dr_FieldPut( cnfld, uVal ) CLASS TDataRow
Code: Select all  Expand view

    ...  
     if ::lReadOnly .or. ( Len( ::aData[ fld ] ) > 2 .and. ::aData[ fld, 3 ] == .f. )
         return ::error(  HB_LangErrMsg( 39 ), ::className(), ::FieldName( fld ), 39, { uVal } )
   ...
 


Is it possible tDataRow works in the same way as ADO ?

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

Re: Mysql ADO and TDataRow

Postby nageswaragunupudi » Wed Jun 28, 2017 1:59 am

We made autoinc field readonly both in XBrowse and TDatRow. We also made it difficult to change it.

Still you can make the field read-write as below

oRec:aData[ oRec:FieldPos( "NUMBER" ), 3 ] := .T.

But the real question is why there can be blank values in an autoinc field? We should never let it happen.
Regards

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

Re: Mysql ADO and TDataRow

Postby Maurizio » Wed Jun 28, 2017 7:10 am

Thanks Rao ,

When I need to use your advice .

<< But the real question is why there can be blank values in an autoinc field? We should never let it happen.

I have to put a real values not a blank values .

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

Re: Mysql ADO and TDataRow

Postby nageswaragunupudi » Wed Jun 28, 2017 8:36 am

Please download 17.06 again

oRec:FieldReadOnly( "NUMBER", .F. )
Regards

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

Re: Mysql ADO and TDataRow

Postby Maurizio » Wed Jun 28, 2017 9:13 am

Thanks Rao ,

If I use

oRec := TDataRow():New( oRs, nil, .t.)
oRec:FieldReadOnly( "NUMBER", .F. )

I have this error when append a record

Code: Select all  Expand view
 Time from start: 0 hours 0 mins 14 secs
   Error occurred at: 28/06/2017, 11:10:08
   Error description: (DOS Error -2147352567) WINOLE/1007  Un handle di riga fa riferimento a una riga eliminata o a una riga contrassegnata per l'eliminazione. (0x80040E23): Microsoft Cursor Engine

Stack Calls
===========
   Called from:  => TOLEAUTO:VALUE( 0 )
   Called from: .\source\classes\DATAROW.PRG => TDATAROW:READADO( 694 )
   Called from: .\source\classes\DATAROW.PRG => TDATAROW:SAVEADO( 1191 )
   Called from: .\source\classes\DATAROW.PRG => TDATAROW:SAVE( 1011 )



Regards Maurizo
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Mysql ADO and TDataRow

Postby nageswaragunupudi » Wed Jun 28, 2017 9:33 am

I just now tested with this
Code: Select all  Expand view
  oCn   := FW_DemoDB( "ADO" )
   oRs   := FW_OpenRecordSet( oCn, "select * from states" )
   XBROWSER oRs  // note down last ID
   oRec  := TDataRow():New( oRs, nil, .t. )
   oRec:FieldReadOnly( "ID", .f. )
   oRec:Edit()
 

This is working fine for me if
1) I leave ID as 0
OR
2) If I enter a value for ID, which is already not there in the Table

If I enter an existing value for ID I get error
Your error seems to be for some other reason
Please try my sample above
Regards

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

Re: Mysql ADO and TDataRow

Postby Maurizio » Wed Jun 28, 2017 10:16 am

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

Re: Mysql ADO and TDataRow

Postby nageswaragunupudi » Wed Jun 28, 2017 10:40 am

I request you to please try exactly my sample using the FW server and the table. Not with your table.
Then let me see where the problem is
Regards

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

Re: Mysql ADO and TDataRow

Postby Maurizio » Wed Jun 28, 2017 12:39 pm

Sorry Rao ,

I use
Code: Select all  Expand view

#include "FiveWin.ch"
Function Main()
    oCn   := FW_DemoDB( "ADO" )
   oRs   := FW_OpenRecordSet( oCn, "select * from states" )
   XBROWSER oRs  // note down last ID
   oRec  := TDataRow():New( oRs, nil, .t. )
   oRec:FieldReadOnly( "ID", .f. )
   oRec:Edit()
   
   Return nil


https://drive.google.com/file/d/0By2KWC ... sp=sharing

If I write a real number in ID ( Es: 60) I have the same error

Maurizio
User avatar
Maurizio
 
Posts: 824
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 106 guests