Ado and MS Sql

Post Reply
Jack
Posts: 249
Joined: Wed Jul 11, 2007 11:06 am

Ado and MS Sql

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

Re: Ado and MS Sql

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Ado and MS Sql

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

Re: Ado and MS Sql

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

Re: Ado and MS Sql

Post 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
Post Reply