I have encrypted a MS Access Employee table and in order to show the names in xBrowse I have to ADD the columns passing my Dencrypt() function to the row.
I have no problem with doing that and my results are acceptable, however, I can not sort the data in the browse because the underlying data is encrypted.
Instead of adding the Sort to the data .. is there a way to do something
like oLbx2:Sort( "Name" ) ?
Thanks
Rick Lipkin
Here is the code:
- Code: Select all Expand view RUN
oRsVendor := TOleAuto():New( "ADODB.Recordset" )
oRsVendor:CursorType := 1 // opendkeyset
oRsVendor:CursorLocation := 3 // local cache
oRsVendor:LockType := 3 // lockoportunistic
cSQL := "SELECT * From Avendor Order by Lname,Fname"
TRY
oRsVendor:Open( cSQL,xCONNECT )
CATCH oErr
MsgInfo( "Error in Opening AVENDOR table" )
RETURN(.F.)
END TRY
If oRsVendor:eof
Else
oRsVendor:MoveFirst()
oRsVendor:Find( "Lname Like '"+alltrim(cLname)+"%'" )
If oRsVendor:eof
oRsVendor:MoveFirst()
Endif
Endif
lOk2 := .f.
xTITLE := "Emp Browse "//+xDIST
DEFINE WINDOW oWndChild2 MDICHILD ;
FROM 7,7 to 28,55 ;
MENU BuildMenu() ;
NOSYSMENU ;
NOMINIMIZE ;
NOZOOM ;
OF oWind ;
TITLE xTITLE
DEFINE DIALOG oDlg2 RESOURCE "EMPBROW" OF oWndChild2 ;
COLOR RGB(192,192,192), RGB(62,104,130)
REDEFINE xBROWSE oLBX2 ;
RECORDSET oRsVendor ;
ID 111 of oDlg2 ;
AUTOSORT AUTOCOLS LINES CELL
oLbx2:lHScroll := .f. // turn off horiz scroll bar
oLbx2:lRecordSelector := .f.
oLbx2:nMarqueeStyle := MARQSTYLE_HIGHLROW
ADD oCol TO oLbx2 AT 1 DATA {|x| x := _ChkName(Dencrypt(oRsVendor:Fields("Lname"):Value),;
Dencrypt(oRsVendor:Fields("Fname"):Value),;
Dencrypt(oRsVendor:Fields("Mname"):Value))};
HEADER "Name" size 200 ;
Sort( "Lname")
ADD oCol TO oLbx2 AT 2 DATA {|x| x := _ChkActive(Dencrypt(oRsVendor:Fields("Active"):Value))};
HEADER "Active" size 165
...
//----------------------------
Static Func _ChkName( cLast,cFirst,cMiddle )
Local cName
cName := substr("Unk"+space(45),1,45)
cName := substr(alltrim(cLast)+", "+alltrim(cFirst)+" "+;
alltrim(cMiddle)+space(45),1,45)
Return( cName )
Here is the browse:
Here is what the data looks like encrypted: