all groups > sql server programming > october 2003 >
You're in the

sql server programming

group:

Store XML Stream text object in image field


Store XML Stream text object in image field Alex Chan
10/9/2003 10:20:47 PM
sql server programming:
Hi All,

Is it possible to store the XML stream object into SQL Server image field?
The reason that I need to store in such way because this field may store the
PDf or the XML.

I have also pass the XML into the stream object as text type. and use
"WriteText" function to write it into the database but it won't allowed if
it is the image field. But if I change it to ntext field, it works. Is there
anyway to store the text file through the stream to image field of SQL
server.

Thanks and Regards
Alex

Re: Store XML Stream text object in image field Mark J. McGinty
10/10/2003 6:17:00 AM
Storing it should not be a challenge, just pass your XML buffer to the Write
method. You can even use CopyTo to copy from a text stream to a binary
stream.

Unfortunately that's a one-way ticket, because you can't use ReadText on a
binary stream, and you can't use a text stream to access an image field.
Since Read from a binary stream returns a byte array, you could iterate the
array, converting each byte to a character and concatenating an output
buffer with each, but you'll find that to be painfully slow.

The only other way is to use 2 fields, switching between tham as appropriate
based on content.

-Mark




[quoted text, click to view]

Re: Store XML Stream text object in image field bobbyballgame
10/16/2003 3:40:18 PM
And do not forget that there are many different character encodings...

In .NET there might be some binary serializers you could use...I simply do
not know, but if you do not have much control over the character encodings,
parsing these manually can be painful.
Good luck,
BB



[quoted text, click to view]

AddThis Social Bookmark Button