Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert Binary to String for SQL Update
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01524435
Message ID:
01524459
Views:
50
My solution was to write a simple NumToHexString function and loop through the binary to build the lcPersonID string.
  lcPersonID = ""
  FOR i = 1 TO 10
    lcPersonID = lcPersonID + NumToHexStr(ASC(SUBSTR(PersonID,i,1)))
  NEXT 


*-- NumToHexStr--*
LPARAMETERS num
LOCAL nh, nl, sh, sl

If num < 0 or num > 255
  RETURN  "??"
ENDIF 

nh = INT(num / 16)
nl = MOD(num, 16)

sh = IIF(nh < 10, chr(48 + nh), chr(55 + nh))
sl = IIF(nl < 10, chr(48 + nl), chr(55 + nl))

RETURN sh + sl
Previous
Reply
Map
View

Click here to load this message in the networking platform