oCn:insert - Not inserting data (SOLVED)

oCn:insert - Not inserting data (SOLVED)

Postby Marc Venken » Sat Jun 03, 2017 9: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: Select all  Expand view  RUN
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
 
Last edited by Marc Venken on Sun Jun 04, 2017 7:58 pm, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1450
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: oCn:insert - Not inserting data

Postby Rick Lipkin » Sat Jun 03, 2017 1:13 pm

Marc

Here is the code I use for multiple selected rows in xBrowse
Code: Select all  Expand view  RUN

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
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: oCn:insert - Not inserting data

Postby Marc Venken » Sat Jun 03, 2017 6: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1450
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: oCn:insert - Not inserting data

Postby nageswaragunupudi » Sun Jun 04, 2017 1:34 am

oCn:Insert(...) works in all versions.

Please see this part of your code:
Code: Select all  Expand view  RUN

{ 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: Select all  Expand view  RUN

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

Re: oCn:insert - Not inserting data

Postby Marc Venken » Sun Jun 04, 2017 7:58 pm

That was it.

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

Thanks.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1450
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: dtussman and 43 guests