Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > serialize to SQL Server Blob instead of XML serialize

Reply
Thread Tools

serialize to SQL Server Blob instead of XML serialize

 
 
Gordz
Guest
Posts: n/a
 
      06-07-2004
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


 
Reply With Quote
 
 
 
 
John Oakes
Guest
Posts: n/a
 
      06-07-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Gordz
Guest
Posts: n/a
 
      06-07-2004
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" <(E-Mail Removed)> wrote in message
news:OwaYP%(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>




 
Reply With Quote
 
John Oakes
Guest
Posts: n/a
 
      06-07-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:OwaYP%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using IIS ASP to display a blob field in SQL Server 2005 None@none.com ASP General 4 09-02-2010 04:51 AM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Retrieving BLOB Datatype from SQL Server 2000 nkunapa Java 4 08-10-2005 04:12 PM
Memory Allocation Error when to fetching BLOB field from MS-SQL server Table Bazil Perl Misc 3 11-30-2003 07:50 PM
Could not allocate enough memory ( Fetch a Blob column from a MS-SQL(7) table. SQL) Steve Perl Misc 4 11-28-2003 06:00 PM



Advertisments