BLOB data insertion and retreival across language RRS feed

  • Question

  • Hi,

    I have a query regarding the insertion and retreival of BLOB data from SQL Server.

    I have a table with column of type "image".  I am storing structure from Visual C++.
    Is it possible to retreive the same structure using ADO.Net Data Provider using C#.

    Also, the structure may be something like this

    class Panel
    int Id;
    CString  Notes;
    DWORD SubPartId;

    Thanks in advance.

    Wednesday, October 15, 2008 1:22 PM

All replies

  • Do you need to retrieve structure description and create actual type in C#? If yes, you would need to serialize type first before storing it into database and then de-serialize after you retrieved stored content from database.


    Wednesday, October 15, 2008 8:55 PM

    Thanks for the reply.


    Yes I need to retreive the strucuture as has been inserted. I am able to receive an array of bytes while reading the Blob field, but when i deserialize it to System.Object it throws the following exception -


    {System.Runtime.Serialization.SerializationException: The input stream is not a valid binary format. The starting contents (in bytes) are: FF-FF-0F-00-09-00-43-53-65-72-50-61-6E-65-6C-FF-FE ...






    Thursday, October 16, 2008 5:07 AM
  • Most likely data was not stored or retrieved properly. Here is the link to KB article about how to work with BLOB data



    Thursday, October 16, 2008 6:03 PM
  • Thanks for the response. I had one basic doubt.

    Is it possible to deserialize the structure in C# which has been serialized in VC++.  The structure has been serialized  using VC++ MFC CArchive class. I am wondering if we can gracefuuly deserailize the same object in C#  to get the values.

    Friday, October 17, 2008 9:29 AM
  • It would work if you use .NET Framework serialization classes from VC++. If it uses something outside of .NET Framework, I would doubt it will work.

    Friday, October 17, 2008 8:55 PM