locked
Binary data corruption RRS feed

  • Question

  • User-1350516731 posted

    Hello all!

    I'm trying to store in SQL Server 2017 binary value from C# bytes array. 

    I have store it in BINARY field ContosoField via SqlTypes.SqlBinary parameter execution. Then, I want to get back my byte[] array using this: (byte[])ContosoFieldValue but I see another value in result. How to correctly store byte[] in SQL Server storage and get it back into byte[] in condition?

    Thank you.

    Saturday, August 11, 2018 5:37 PM

Answers

  • User1724605321 posted

    Hi Alex ,

    (byte[])ContosoFieldValue but I see another value in result.

    If the sizes of the column data entries vary considerably , use varbinary What is the problem when convert to byte array with (byte[]) ?

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2018 7:02 AM

All replies

  • User475983607 posted

    Share your code if you need help debugging. Or post sample code that reproduces the behavior.
    Saturday, August 11, 2018 5:44 PM
  • User1724605321 posted

    Hi Alex ,

    (byte[])ContosoFieldValue but I see another value in result.

    If the sizes of the column data entries vary considerably , use varbinary What is the problem when convert to byte array with (byte[]) ?

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 13, 2018 7:02 AM