Ado and MS Sql

Ado and MS Sql

Postby Jack » Thu Dec 17, 2015 7:42 am

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
Jack
 
Posts: 280
Joined: Wed Jul 11, 2007 11:06 am

Re: Ado and MS Sql

Postby nageswaragunupudi » Thu Dec 17, 2015 8:29 am

Please try
Code: Select all  Expand view
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.
Regards

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

Re: Ado and MS Sql

Postby Rick Lipkin » Thu Dec 17, 2015 1:13 pm

Jack

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


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  Expand view



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

Re: Ado and MS Sql

Postby Jack » Fri Dec 18, 2015 10:40 am

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
Jack
 
Posts: 280
Joined: Wed Jul 11, 2007 11:06 am

Re: Ado and MS Sql

Postby Rick Lipkin » Fri Dec 18, 2015 1:04 pm

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests