Re: AppendChunk method resulting in wrong data
- From: "Mark J. McGinty" <mmcginty@xxxxxxxxxxxxxxx>
- Date: Mon, 25 Jun 2007 03:37:38 -0700
<everymn@xxxxxxxxx> wrote in message
news:lgim73l51d8l2h7vpblhdv5anh67pospqk@xxxxxxxxxx
I've determined where the extra byte is coming from but I'm not sure
what to do about it. I'm doing this in VBs, and since byte() are not
supported there I'm calling a DLL I made in VB6 to create and modify
them for me. When I do this...
' get a reference an empty byte array
' to read byte arrays from test file
binArr = TestFunctions.GetByteArr()
I'm calling...
Public Function GetByteArr() As Byte()
Dim arr(0) As Byte
GetByteArr = arr
End Function
If I change the dimension to arr(10), then the length of my final
parameter value goes up by 10. What I'm unlear about is that
supposedly the first time you call appendChunk, it's supposed to
initialize the variable. I've tried to dimension it as arr() as Byte,
but then when I do this it tells me I'm trying to use the wrong data
type.
Set param1 = command1.CreateParameter( _
"@binValue", adLongVarBinary, _
adParamInput,_
fileSize+1, binArr)
Is there a more appropriate way to initialize the array that I haven't
tried?
Have you tried omitting the value arg when you create the parameter object?
Perhaps CreateParameter internally calls AppendChunk if/when a value is
explicitly passed?
Also, there is another way to transfer blob values that works with recordset
fields, so should work with Parameter values as well:
Dim s As ADODB.Stream
Set s = New ADODB.Stream
s.Mode = adModeReadWrite
s.Type = adTypeBinary
s.Open
' load binary contents of into stream
' assumes FileName is the name of an existing file
s.LoadFromFile FileName
' set position to beginning of stream
s.Position = 0
' insert a row (or otherwise position record pointer)
rs.AddNew
' assign other fields as required
' ...
' assumes image field name is 'blob'
rs.Fields("blob").value = s.Read()
rs.Update
s.Close
-Mark
Thanks
Eric
.
- Follow-Ups:
- Re: AppendChunk method resulting in wrong data
- From: everymn
- Re: AppendChunk method resulting in wrong data
- References:
- AppendChunk method resulting in wrong data
- From: everymn
- Re: AppendChunk method resulting in wrong data
- From: everymn
- AppendChunk method resulting in wrong data
- Prev by Date: ado
- Next by Date: Re: ado
- Previous by thread: Re: AppendChunk method resulting in wrong data
- Next by thread: Re: AppendChunk method resulting in wrong data
- Index(es):
Relevant Pages
|