Page 1 of 1

Ado and MS Sql

Posted: Thu Dec 17, 2015 7:42 am
by Jack
Hello,
I use a record set to display a table of Customer from a MS SQL database.
I do not want to use autoedit .
When the user dblclick on a line, i open a dialog and ask FirstName,LastName, PhoneNumber.
When the user click on save, i can do an UPDATE SQL instruction but when i come back in the XBROWSE, the new value is not Displayed .
I can do a REQUERY but the record pointer goes on top of XBrowse

The second way is to close the Dialog and do : oRs:Fields("fieldname"):Value := 'MyValue' oRs:Update() .

What is the best way ?

With standard DBF, we REPLACE the field with new value, come back in the Xbrowse and make a REFRESH .

Thanks

Re: Ado and MS Sql

Posted: Thu Dec 17, 2015 8:29 am
by nageswaragunupudi
Please try

Code: Select all

oBrw:bLDClickDatas := { || oBrw:EditSource( .f., "FirstName,LastName,PhoneNumber", .f. )}
XBrowse internally invokes TDataRow class to edit the contents of the fields and save them properly and update xbrowse.

I assume the recordset fieldnames are FirstName, LastName and PhoneNumber.

Re: Ado and MS Sql

Posted: Thu Dec 17, 2015 1:13 pm
by Rick Lipkin
Jack

A simple oLbx:ReFresh() will work .. you can place it at the bottom of your dialog edit .. consider this code :

Code: Select all


oLbx:bLDblClick := { |nRow,nCol | _InvtView( "V", oWnd, oWndChildA, oRsInvt,oLbx,;
                                                     oBtn1,oBtn2,oBtn3,oBtn4,oBtn5,oBtn6,oBtn7,oBtn8 ) }

 
As you can see I am passing the oLbx object and when just before I return from _InvView() I do oLbx:ReFresh() .. Hope that helps.
Rick Lipkin

Code: Select all



oRsInvt:Fields("DateIssued"):Value             := dDateIssued
oRsInvt:Fields("Lname"):Value                  := cLname
oRsInvt:Fields("Fname"):Value                  := cFname
oRsInvt:Fields("FullName"):Value               := cFullName
oRsInvt:Fields("UserId"):Value                 := cUserId
oRsInvt:Fields("Location"):Value               := cLoc
oRsInvt:Fields("Department"):Value             := cDept
oRsInvt:Fields("Category"):Value               := cCat
oRsInvt:Fields("Manufacturer"):Value           := cMan
oRsInvt:Fields("Asset"):Value                  := cAsset
oRsInvt:Fields("SerialNumber"):Value           := cSerialNumber
oRsInvt:Fields("Specs"):Value                  := cSpecs
oRsInvt:Fields("RetroFitSSD"):Value            := cSSD
oRsInvt:Fields("Phone"):Value                  := cPhone
oRsInvt:Fields("Cost"):Value                   := nCost
oRsInvt:Fields("DatePurchased"):Value          := dDatePurch
oRsInvt:Fields("Comments"):Value               := cComments
oRsInvt:Fields("EntryBy"):Value                := xLogin
oRsInvt:Fields("EntryDate"):Value              := dtoc(date())+" "+time()
oRsInvt:Fields("Status"):Value                 := cStatus

oRsInvt:Update()


If cMode = "A".or. cMode = "E"

   If cMode = "E"
      nEId := oRsInvt:Fields("InventEid"):Value
   Endif

   oRsInvt:Filter := ""
   oRsInvt:Sort := "Lname"
   oRsInvt:MoveFirst()
   oRsInvt:Find( "[InventEid] = "+ltrim(str(nEid)) )
   If oRsInvt:eof
      oRsInvt:MoveFirst()
   Endif
Endif

oLbx:ReFresh()  // refresh browse with new or edited data

RETURN(NIL)
 

Re: Ado and MS Sql

Posted: Fri Dec 18, 2015 10:40 am
by Jack
Thanks for this answer .

I suppose the best way is to pass the ListBox and the Recordset to the function .
Is it passed by Value of Adress ?

Thanks

Re: Ado and MS Sql

Posted: Fri Dec 18, 2015 1:04 pm
by Rick Lipkin
Jack

You can pass objects without any special considerations .. objects are containers of :values() not necessarily memory pointers to a specific variable that may need to prefixed by reference.

Rick Lipkin