468,720 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

serialize to SQL Server Blob instead of XML serialize

I've been experiencing problems on some computers with XML Serialization. On
some computers the files do not get created on the web server's hard drive
and it's been driving me nuts trying to figure it out.

I store navigation history and application state in object collections and
save this upon application exit by doing an XML.Serialize.

I'd like to serialize directly to SQL Server instead. Can I create a stream
object to be used by SQL Server with serialization?

Thanks
Nov 18 '05 #1
3 1852
Yeah, this is the basics (DT is just an object I'm taking from session and
serializing):

Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()

Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function

-John Oakes
"Gordz" <jo*****@aol.com> wrote in message
news:10************@corp.supernews.com...
I've been experiencing problems on some computers with XML Serialization. On some computers the files do not get created on the web server's hard drive
and it's been driving me nuts trying to figure it out.

I store navigation history and application state in object collections and
save this upon application exit by doing an XML.Serialize.

I'd like to serialize directly to SQL Server instead. Can I create a stream object to be used by SQL Server with serialization?

Thanks

Nov 18 '05 #2
thanks John.

I've never used binary objects in SQL before.

Where exactly is your data "@DesktopData" stored in the database? Do you
have a field already defined?

Cheers,

Gord

"John Oakes" <jo**@nospam.networkproductions.net> wrote in message
news:Ow****************@TK2MSFTNGP12.phx.gbl...
Yeah, this is the basics (DT is just an object I'm taking from session and
serializing):

Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()

Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function

-John Oakes
"Gordz" <jo*****@aol.com> wrote in message
news:10************@corp.supernews.com...
I've been experiencing problems on some computers with XML Serialization. On some computers the files do not get created on the web server's hard drive
and it's been driving me nuts trying to figure it out.

I store navigation history and application state in object collections and
save this upon application exit by doing an XML.Serialize.

I'd like to serialize directly to SQL Server instead. Can I create a stream object to be used by SQL Server with serialization?

Thanks


Nov 18 '05 #3
Yes, I have a field defined. The datatype is image, which is
variable-length binary data from 0 through 231-1 (2,147,483,647) bytes.

-John Oakes
"Gordz" <jo*****@aol.com> wrote in message
news:10*************@corp.supernews.com...
thanks John.

I've never used binary objects in SQL before.

Where exactly is your data "@DesktopData" stored in the database? Do you
have a field already defined?

Cheers,

Gord

"John Oakes" <jo**@nospam.networkproductions.net> wrote in message
news:Ow****************@TK2MSFTNGP12.phx.gbl...
Yeah, this is the basics (DT is just an object I'm taking from session and
serializing):

Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()

Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function

-John Oakes
"Gordz" <jo*****@aol.com> wrote in message
news:10************@corp.supernews.com...
I've been experiencing problems on some computers with XML Serialization.
On
some computers the files do not get created on the web server's hard

drive and it's been driving me nuts trying to figure it out.

I store navigation history and application state in object collections and save this upon application exit by doing an XML.Serialize.

I'd like to serialize directly to SQL Server instead. Can I create a

stream
object to be used by SQL Server with serialization?

Thanks


Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Sworder | last post: by
9 posts views Thread by Hrvoje Voda | last post: by
6 posts views Thread by Rod Snyder | last post: by
3 posts views Thread by =?Utf-8?B?UGhpbCBKb2huc29u?= | last post: by
46 posts views Thread by RAZZ | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.