FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oCn:insert - Not inserting data (SOLVED)
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
oCn:insert - Not inserting data (SOLVED)
Posted: Sat Jun 03, 2017 09:58 AM
With this code, i was trying to insert a line whenever a selected row will be processed.

I have seen the topic, (from version 16.08) I have 16.11

oCn:Insert( "changes", "bond, naam, voornaam,oldploeg,newploeg,datum", { oBrw:naam, oBrw:voornaam, oBrw:p2017, cPloeg, date() } )

I believe this should work. The oCn is open and working : FWCONNECT oCn HOST cServer USER cUser PASSWORD cPassword DATABASE cDatabase
I see no error when this code is executed.

What should I change?

Code (fw): Select all Collapse
function setploeg(oBrw,cPloeg)

    local uSavePos := oBrw:BookMark

    if msgYesNo(str(LEN(oBRW:aSELECTED),3)+"-> Geselecteerde leden verplaatsen")
        FOR I = 1 TO LEN(oBRW:aSELECTED) // obrw:aSELECTED is an array containing recnos marked
          oCn:Insert( "changes", "bond, naam, voornaam,oldploeg,newploeg,datum", { oBrw:naam, oBrw:voornaam, oBrw:p2017, cPloeg, date() } )

          oBrw:BookMark := oBrw:aSelected[ i ]   // works for dbf, rowset, ado and all
          oBrw:p2017:VarPut( cPloeg ) // Works for dbf, rowset, ado and all
        next
    endif

    oBrw:BookMark := uSavePos

return NIL
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: oCn:insert - Not inserting data
Posted: Sat Jun 03, 2017 01:13 PM
Marc

Here is the code I use for multiple selected rows in xBrowse
Code (fw): Select all Collapse
aCols := oLbx:aSelected

For i = 1 to Len(aCols)

   oLbx:BookMark := aCols[i]
   _TransFer( oRsInvt,oWnd,oLbxMain,oRsDetail,;
                      oWndChildD,oRsRepair,@lTaxable,oTaxable,oFontB,oFontBig,nRepairNumber,;
                      oLabor,oParts,oMisc,oTax,oTotal,nAssignedTo,cLoc,cTaxSet,;
                      oLbx,oBtn1,oBtn2,oBtn3  )

Next


_Transfer() opens a recordset and I oRs:AddNew() .. modify my fields and oRs:Update() .. I find opening and updating a recordset much more straight forward and easier for me to code than to do a Sql Set Insert. I realize you are probably using My Sql which is coded a bit differently.

Review the For Next loop above to access your bookmarked ( hi-lighted rows ) and you can update your table accordingly.

Rick Lipkin
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: oCn:insert - Not inserting data
Posted: Sat Jun 03, 2017 06:32 PM

Rick,

Every item from Xbrowse in the loop is updated correctly !

I want to insert a new row in a database 'changes' so I can trace changes that have been made by others.

oCn:Insert( "changes", "bond, naam, voornaam,oldploeg,newploeg,datum", { oBrw:naam, oBrw:voornaam, oBrw:p2017, cPloeg, date() } )

The insert should do this, but nothing happens (also no error)

I suppose that it is later than version 16.11.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oCn:insert - Not inserting data
Posted: Sun Jun 04, 2017 01:34 AM
oCn:Insert(...) works in all versions.

Please see this part of your code:
Code (fw): Select all Collapse
{ oBrw:naam, oBrw:voornaam, oBrw:p2017, cPloeg, date() }

oBrw:naam returns the column object, not value. That is the error.
You should be using
Code (fw): Select all Collapse
{ oBrw:naam:Value, oBrw:voornaam:Value, oBrw:p2017:Value, cPloeg, date() }


During development, I advise you to set oCn:lShowErrors := .t
Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: oCn:insert - Not inserting data
Posted: Sun Jun 04, 2017 07:58 PM

That was it.

I had more issues with missing this.... Also solved..

Thanks.

Marc Venken

Using: FWH 23.08 with Harbour

Continue the discussion