how to read the hexadecimal value from sql server using C#

  • Hi,

    I have a problem in reading the hexadecimal value from sql server using C#

    Table Structure :

    TableA

    ------

    Column Name -   DataType

    -----------------------

    audioFileId  -  Int

    audioOriginalData  - Image

    The audio file size will be 20kb  and above. So i have kept the data type for "audioOriginalData" column as image  and then i dumped the audio file in the database.

    Sample Data:

    ------------

    audioFileId - audioOriginalData

    ------  -----------------

    1  - 0x2321414D520A3C084F9C189CF86660E0E66A346

    2  - 0x2321414D525A3C064F9C186CF86660E0E66A346

    3  - 0x2321414D525A3C064F9C186CF86660E0E66A346

    I want to generate a xml file with the id and the hexa decimal value.

    Example :

    <audiodetails>

     <audiofileid>1</id>

     <audiooriginaldata>0x2321414D520A3C084F9C189CF86660E0E66A346</audiooriginaldata>

    <audiodetails>

    I tried to read the database details using "SqldataReader", it says "System.Byte[]" for the "audiooriginaldata" column. Then i tried with DataSet.GetXml(), 'm not getting the hexadecimal value.

    Please help.

    thankx,

    pousi

  • >> I tried to read the database details using "SqldataReader", it says "System.Byte[]" for the "audiooriginaldata" column.

    That's because that's what an Image data type is - a sequence (array) of bytes. If what you actually want is the hexadecimal string representation of that array of bytes, probably something like ToString("x") will give you what you want (I am not a .net expert!)

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply