serialize to SQL Server Blob instead of XML serialize

Discussion in 'ASP .Net' started by Gordz, Jun 7, 2004.

  1. Gordz

    Gordz Guest

    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
     
    Gordz, Jun 7, 2004
    #1
    1. Advertising

  2. Gordz

    John Oakes Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
     
    John Oakes, Jun 7, 2004
    #2
    1. Advertising

  3. Gordz

    Gordz Guest

    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" <> wrote in message
    news:OwaYP%...
    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" <> wrote in message
    news:...
    > 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
    >
    >
     
    Gordz, Jun 7, 2004
    #3
  4. Gordz

    John Oakes Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:OwaYP%...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >

    >
    >
    >
     
    John Oakes, Jun 7, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nkunapa
    Replies:
    4
    Views:
    6,748
    nkunapa
    Aug 10, 2005
  2. =?Utf-8?B?QW5kcsOp?=

    sql server serialize session state

    =?Utf-8?B?QW5kcsOp?=, Oct 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    704
    =?Utf-8?B?QW5kcsOp?=
    Oct 4, 2006
  3. Replies:
    4
    Views:
    1,509
    Bwig Zomberi
    Sep 2, 2010
  4. Steve
    Replies:
    4
    Views:
    391
    James Willmore
    Nov 28, 2003
  5. Bazil
    Replies:
    3
    Views:
    346
    William Herrera
    Nov 30, 2003
Loading...

Share This Page