Re: how to update binary field types in ADO



One technique suggested by Paul Randall works in some cases. He writes a hex
value to an ADO stream, then reads it back as a byte array. This may help
you:
===============
Function HexStrToOctet(strInput)
' Function to convert hex string to an OctetString (byte array).
' Based on a program by Paul Randall, October, 2002.

Dim orginalLocale, adoStream

' Retain original locale setting.
originalLocale = SetLocale(1033)

Set adoStream = CreateObject("ADODB.Stream")

' Write hex string to stream.
adoStream.Type = 2
adoStream.Charset = "x-ansi"
adoStream.Open
adoStream.WriteText strInput, 0

' Read stream as byte array.
adoStream.Position = 0
adoStream.Type = 1
HexStrToOctet = adoStream.Read

' Restore original locale setting.
SetLocale(originalLocale)
End Function

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: how to update binary field types in ADO
    ... called hex conversion? ... Is text stored as a hex array? ... Although the stream converson is a handy idea, I'm not sure how I'd go ... Have I not created an array of bytes? ...
    (microsoft.public.scripting.vbscript)
  • Re: Big endian convention in Ruby
    ... if the array holding this is ... messageHex[0].hex.to_i this will ensure that it is a integer in hex. ... Unpack directly to Integers, as shown above. ... It works perfectly fine with in give the loop 64 times.. ...
    (comp.lang.ruby)
  • Re: increasing the size of a byte array and reading streams
    ... > reading the stream below (where buf is a byte array). ... When you're reading a file, for example, and you know that the file is ... There are times, however, when it makes sense to read a stream in small ... write those uncompressed bytes to your secondary MemoryStream. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Handling blank lines in while(<CONF>) construct
    ... This is the terminal code to produce a yellow text output. ... If I were watching my maillog file stream past, ... This array is created dynamically by the code ... I posted the code to the list yesterday, ...
    (perl.beginners)
  • Re: How to save C++ objects using Cocoa?
    ... from my perspective it seems like with a byte stream I have to invent ... have to archive the array. ... imply that Cocoa streamlines the whole lot; ... flattening the data to saving it; I wasn't sure why, or if, this was ...
    (comp.sys.mac.programmer.help)