Scott,
Unless you have to manupulate the values of the bytes, you should just
call the Stream property on the SqlBytes instance. This will return a
stream of bytes that taps into the TDS stream that SQL Server returns. If
you call the Buffer property, it will read the entire contents of the stream
into memory. It's not the MemoryStream that is helping you, it is the call
to Buffer.
As for will it always be reliable? Well, no, but that's the nature of
things. Any number of things could go wrong. What if someone pulls the
network cord while reading the contents from the stream?
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"scottrm" <sc*****@newsgroup.nospamwrote in message
news:35**********************************@microsof t.com...
>I have the following code
System.Data.SqlTypes.SqlBytes bytes = reader.GetSqlBytes(columnIndex);
MemoryStream ms = new MemoryStream(bytes.Buffer);
My question is will the Buffer property of SqlBytes reliable get all the
data from the bytes retreived from the GetSqlBytes function. It seems to
do
so in my testing but will this always be the case. The documentation is a
bit
sparse on this. It was the only way I could find to populate a memory
stream
from the SqlBytes.
--
Scott