How to deal with serialized data and a database RRS feed

  • Question

  • Hi everyone,
      So here is what I'm trying to do.  I am trying a binary-serialized object, and put it into a database.  Basically, I am removing the need for many columns, by serializing the whole object, and am using a few key data members to work as a primary key.  However, I can't figure out how to get the serialized object into my oracle database?  So far, here is what I have come up with:

    Code Snippet

    string myBinaryData = "";

    BinaryFormatter bf = new BinaryFormatter();

     MemoryStream ms = new MemoryStream();

     foreach (MyObject myObject in allMyObjects)
        bf.Serialize(ms, myObject);

     byte[] dataByte = ms.GetBuffer();
     foreach(byte oneByte in dataByte)
        myBinaryData +=  Convert.ToChar(oneByte);

    After this code is executed, I am going to insert the string variable into, my dataset, then send the dataset to the database, using a BLOB field for the binary data.

    Does that make any sense at all?  Am I way off?  Or is there a better way to do it?
    Friday, July 20, 2007 5:38 PM