Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a StrToHex API function?
Message
From
04/02/2002 05:57:39
 
 
To
04/02/2002 05:03:12
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00614674
Message ID:
00614679
Views:
35
I just found a solution. Albert Ballinger's great utility FoxCrypto.fll (see http://fox.wikis.com/wc.dll?Wiki~FoxCrypto~VFP) has a function called HexEncoder which does exactly this. This function is soooooo fast. My StrToHex() version written in VFP took 127 seconds to convert a 180KB file. Albert's function does it in 0.1 second!!!

Vlad, you may want to update your FAQ to mention this as an alternative solution?

>This is a follow-up on Vlad's FAQ#7995 regarding the difficulties to update SQL Server image fields with binary data when using SPT. So far I've been using the workaround suggested in the FAQ. The workaround is quite involved and requires an extra copy to disk. Last week I was looking into this problem again as I thought that there must be an easier way to do this.
>
>I used the SQL Profiler and found that binary data is actually sent in HEX format. For example, the string "Hello World" is sent as 0x48656C6C6F20576F726C64. I then created a simple program that converts a string into HEX format. This allows me to insert binary data into SQL Server with the following syntax:
>
>?SQLEXEC(nSql, "UPDATE MyTable SET ImageField = " + StrToHex(FILETOSTR(MyBinaryFile)) + " WHERE PkField=1")
>
>
>This works well and the same approach could also be used to send binary data to a stored procedure. The problem is speed. My function StrToHex() loops through the file character by character. Needless to say that this is very slow. Does anyone know of an API/FLL function that converts a string into HEX? The funny thing is that VFP internally does exactly this when using SPT or a remote view.
>
>TIA
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform