Re: AppendChunk method resulting in wrong data

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




<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


.



Relevant Pages

  • Re: AppendChunk method resulting in wrong data
    ... ' load binary contents of into stream ... ' assumes FileName is the name of an existing file ... ' set position to beginning of stream ... ' insert a row (or otherwise position record pointer) ...
    (microsoft.public.vb.database.ado)
  • Re: AppendChunk method resulting in wrong data
    ... sure how it could be used to chunk-up a blob parameter -- I take it you're ... stream may not offer you any advantages. ... ' set position to beginning of stream ... ' insert a row (or otherwise position record pointer) ...
    (microsoft.public.vb.database.ado)
  • Re: ImageList for Console Application
    ... I don't know if this will work with a stream from the resource..but here is ... public string WriteToTempFile ... System.IO.StreamWriter writer = null; ... fileName = System.IO.Path.GetTempFileName; ...
    (microsoft.public.dotnet.general)
  • Re: context.Response.OutputStream.Write(buffer, 0, count) questions
    ... And it worked except for the crazy filename in the dialog box. ... Dim size As PhotoSize = PhotoSize.Original ... Dim stream As IO.Stream = Nothing ... Dim count As Integer = stream.Read(buffer, 0, buffersize) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HOWTO: Force the SaveAs Dialog Box For Downloads
    ... then stream the content to the client. ... >> The following code should work, according to Microsoft, but downloads ... >> Dim Contents ... >> FileName = Request.QueryString ...
    (microsoft.public.inetserver.asp.general)