Wednesday, March 28, 2012

Saving ParameterValue Object To SQL Table

Greetings,
I am trying to store/retrieve given RS report's ParameterValue object to a
SQL table (ntext?)â?¦Iâ've tried MemoryStream w/ BinaryFormatter and am getting
â'Not marked as serializableâ' errors. Any suggestions on a viable way to do
this would be appreciated.
Thank you for your time!
JohnI solved my problem using the XmlSerializer object as followingsâ?¦
Public Shared Function Deserialize(ByVal bytes() As Byte) As Object
Dim xs As New XmlSerializer(GetType(ParameterValue()))
Dim ms As New MemoryStream(bytes)
Dim obj As Object
Try
obj = xs.Deserialize(ms)
Catch ex As Exception
Throw ex
End Try
Return obj
End Function
Public Shared Function Serialize(ByVal Obj() As Object) As Byte()
Dim xs As New XmlSerializer(GetType(ParameterValue()))
Dim Ms As New MemoryStream
Try
xs.Serialize(Ms, Obj)
Catch ex As Exception
Throw ex
End Try
Return Ms.ToArray
End Function
Dim Rp() as ParameterValue
â'Store parameter object
DataRow(â'MyBinaryFieldâ') = Serialize(Rp())
â'Get Stored Parameter object
Rp = Deserialize(DataRow(â'MyBinaryFieldâ'))
"JB" wrote:
> Greetings,
> I am trying to store/retrieve given RS report's ParameterValue object to a
> SQL table (ntext?)â?¦Iâ've tried MemoryStream w/ BinaryFormatter and am getting
> â'Not marked as serializableâ' errors. Any suggestions on a viable way to do
> this would be appreciated.
> Thank you for your time!
> John
>sql

No comments:

Post a Comment