appendChunk method resulting in incorrect data



Hi,
Having a bit of trouble with the Parameter.AppendChunk method. The
test output from the below code is as follows:

Trace: param first byte: 0
Trace: param second byte: 255
Trace: Source first byte: 255
Trace: Original file length: 711
Trace: total bytes appended to param: 711
Trace: final param length: 712
Trace: param last byte: 217
Trace: Source last byte: 217

For some reason it appears that the first time I'm call the method,
it's putting a 0 in the first byte of the Parameter value. It's my
understanding that the first time the method is called it's supposed
to replace the current contents of the value, and when I've done these
tests against field objects using that that object's version of the
same method it works fine.

In this case however, after I've stored the data to the parameter's
value field it is always 1 byte longer than the original data and when
I call Command.Execute, that same data with the extra 0 byte is stored
to the data source.

Unless I've done something specifically wrong here, it appears that
this might be an ADO bug because I've tried it against two different
data source providers and have the same results.

Thanks
Eric

' get a reference an empty byte array
' to read byte arrays from test file
binArr = TestFunctions.GetByteArr()

Set param1 = command1.CreateParameter( _
"@binValue", adLongVarBinary, _
adParamInput,_
fileSize+1, binArr)

Set param2 = command1.CreateParameter( _
"@Key", adInteger, _
adParamInput, 0, 0)

command1.Parameters.Append param1
command1.Parameters.Append param2
command1.Parameters("@Key") = 1

For each col_name in testArr
strSQL = "UPDATE ado_test SET " & _
col_name & " = ? WHERE " & key_column & " = ?"
command1.CommandText = strSQL

blockSize = 100

While bytesTotalWritten <> fileSize
If fileSize - bytesTotalWritten < blockSize Then
blockSize = fileSize - bytesTotalWritten
End If

' Reads binary file on block at a time
iReturn = TestFunctions.GetBytesFromFile( _
binArr, bytesTotalWritten, _
blockSize, FILE )

' write the bytes to the field
command1.Parameters("@binValue").AppendChunk (binArr)

'DEBUG
If bFirst Then
Assert.Trace "param first char: " & Int(ascB(MidB
(command1.Parameters("@binValue"), 1,1)))
Assert.Trace "param second char: " & Int(ascB(MidB
(command1.Parameters("@binValue"), 2,1)))
Assert.Trace "Source first char: " & Int(ascB(MidB (binArr,1,1)))
End If

bytesTotalWritten = bytesTotalWritten + blockSize
bFirst = cBool(false)
Wend

' DEBUG
Assert.Trace "Original file length: " & fileSize
Assert.Trace "total bytes appended to param: " & bytesTotalWritten
Assert.Trace "final param length: " &
lenB(command1.Parameters("@binValue"))

Assert.Trace "param last char: " & Int(ascB(MidB
(command1.Parameters("@binValue"), 712,1)))
Assert.Trace "Source last char: " & Int(ascB(MidB (binArr,11,1)))

command1.execute
Next
.



Relevant Pages

  • AppendChunk method resulting in wrong data
    ... Trace: param second byte: 255 ... data source providers and have the same results. ... If fileSize - bytesTotalWritten < blockSize Then ...
    (microsoft.public.vb.database.ado)
  • RE: multiple asp:contents requires multiple datasources?
    ... I was replying too quick. ... A few corrections to my previous reply: ... "Trace" option is only available in your content page. ... The data source control could be placed on your master page and you can ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Obtaining shortcut from clipboard
    ... or trace the content of the data source when ... I provided an implementation for IDocHostUIHandler. ... but never used afterward. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)