JerryKreischer
Programmer
Here's a snippet of code I use in my program which serializes a custom collection I've created (Chk) and store in a table as an image...
The key for me to get this to work was the ms.ToArray()
Now....
How can I DESERIALIZE this back into my collection (Chk)???
I've seen some C# examples, but I code in VB...
Thanx all...
Jerry
Code:
Dim ms As New MemoryStream() ' Create a memory stream...
Dim bf As New BinaryFormatter() ' and a formatter.
bf.Serialize(ms, Chk) ' Serialize the object into the stream.
Dim myConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
myConn.Open()
Dim myCommand As SqlCommand = New SqlCommand("spInsertOrder", myConn)
With myCommand
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@OrderDetails", SqlDbType.Image).Value = ms.ToArray()
.Parameters.Add("@OrderDetailsLen", SqlDbType.Int).Value = ms.Length
End With
The key for me to get this to work was the ms.ToArray()
Now....
How can I DESERIALIZE this back into my collection (Chk)???
I've seen some C# examples, but I code in VB...
Thanx all...
Jerry