xml into varbinay

  • Thread starter Thread starter MeDhanush
  • Start date Start date
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
 
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.
 
Back
Top