xml into varbinay

M

MeDhanush

Hi Friends,
I'm looking for a way to do following..,can sb pl help me.,

I have xml document/xml string that needs to inserted into one of the
column of a SQL Server Table whose data type is varbinay.
Based on my knowledge, only hexadeciaml values are stored in varbinay
column. It can't store alphabets or special characters,i.e.,it can't
store the xml element names.

XmlTextWriter has a method called WriteBinHex(), but it
encodes/converts only element's value to HexaDecimal format, element
name is not encoded/converted to hexadecimal.

So, what my question is what would be the way to encode/convert the
whole xml document/xml string and it's values to hexadecimal format so
that it can be stored in SQL Server's varbinay column.

Thanks for your help
Kishore
 
M

Miha Markic

Hi,

You should convert text (which xml document certainly is) into byte[] array.
See Encoding.GetBytes() mehtod.
But beware that varbinary is max 8000 bytes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top