473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Serialize to a database

Joe
Hello All,

I want to serialize a hashtable to a database table to persist its values
between postbacks. The client requires that I not use ViewState, hence the
database.

The samples in MSDN show how to serialize a class that implements the
ICollection interface to a file. Does anyone know how to serialize to a
database table and conversely de-serialize from the table?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Nov 21 '05 #1
6 2613
All you have to do is serialize the contents as you normally would, which
would produce a set of bytes. Then encode those bytes into base64. When
save the data to some text field in the database.

Then reverse the process to de-serialize.
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:25**********************************@microsof t.com...
Hello All,

I want to serialize a hashtable to a database table to persist its values
between postbacks. The client requires that I not use ViewState, hence
the
database.

The samples in MSDN show how to serialize a class that implements the
ICollection interface to a file. Does anyone know how to serialize to a
database table and conversely de-serialize from the table?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 21 '05 #2
Joe
Thanks Peter.

I am not familiar with the encoding into base64. Do you know of an online
example?

--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Peter Rilling" wrote:
All you have to do is serialize the contents as you normally would, which
would produce a set of bytes. Then encode those bytes into base64. When
save the data to some text field in the database.

Then reverse the process to de-serialize.
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:25**********************************@microsof t.com...
Hello All,

I want to serialize a hashtable to a database table to persist its values
between postbacks. The client requires that I not use ViewState, hence
the
database.

The samples in MSDN show how to serialize a class that implements the
ICollection interface to a file. Does anyone know how to serialize to a
database table and conversely de-serialize from the table?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Nov 21 '05 #3
Joe
Pater,

One more qeustion. Why encode in Base64?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Peter Rilling" wrote:
All you have to do is serialize the contents as you normally would, which
would produce a set of bytes. Then encode those bytes into base64. When
save the data to some text field in the database.

Then reverse the process to de-serialize.
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:25**********************************@microsof t.com...
Hello All,

I want to serialize a hashtable to a database table to persist its values
between postbacks. The client requires that I not use ViewState, hence
the
database.

The samples in MSDN show how to serialize a class that implements the
ICollection interface to a file. Does anyone know how to serialize to a
database table and conversely de-serialize from the table?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Nov 21 '05 #4
The reason is that when you serialize something, at least in binary format,
there are characters that may not play well with text fields. These are
often the control and extended characters. Base64 simple ensures that all
content can be interpreted as ASCII text. Although this may or may not be
necessary, I usually do this to prevent any subtle bugs when stored or
transmitting the data.

You can use the methods Convert.FromBase64String(...) and
Convert.ToBase64String(...).
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:98**********************************@microsof t.com...
Pater,

One more qeustion. Why encode in Base64?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Peter Rilling" wrote:
All you have to do is serialize the contents as you normally would, which
would produce a set of bytes. Then encode those bytes into base64. When
save the data to some text field in the database.

Then reverse the process to de-serialize.
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:25**********************************@microsof t.com...
> Hello All,
>
> I want to serialize a hashtable to a database table to persist its
> values
> between postbacks. The client requires that I not use ViewState, hence
> the
> database.
>
> The samples in MSDN show how to serialize a class that implements the
> ICollection interface to a file. Does anyone know how to serialize to
> a
> database table and conversely de-serialize from the table?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Nov 21 '05 #5
Joe
Thank you very much. I aprpeciate it.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Peter Rilling" wrote:
The reason is that when you serialize something, at least in binary format,
there are characters that may not play well with text fields. These are
often the control and extended characters. Base64 simple ensures that all
content can be interpreted as ASCII text. Although this may or may not be
necessary, I usually do this to prevent any subtle bugs when stored or
transmitting the data.

You can use the methods Convert.FromBase64String(...) and
Convert.ToBase64String(...).
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:98**********************************@microsof t.com...
Pater,

One more qeustion. Why encode in Base64?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Peter Rilling" wrote:
All you have to do is serialize the contents as you normally would, which
would produce a set of bytes. Then encode those bytes into base64. When
save the data to some text field in the database.

Then reverse the process to de-serialize.
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:25**********************************@microsof t.com...
> Hello All,
>
> I want to serialize a hashtable to a database table to persist its
> values
> between postbacks. The client requires that I not use ViewState, hence
> the
> database.
>
> The samples in MSDN show how to serialize a class that implements the
> ICollection interface to a file. Does anyone know how to serialize to
> a
> database table and conversely de-serialize from the table?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Nov 21 '05 #6
if you use a binary field you can just store the serialized byte array. if
you serialize to xml, then a text field is fine.

-- bruce (sqlwork.com)

"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:98**********************************@microsof t.com...
Pater,

One more qeustion. Why encode in Base64?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Peter Rilling" wrote:
All you have to do is serialize the contents as you normally would, which
would produce a set of bytes. Then encode those bytes into base64. When
save the data to some text field in the database.

Then reverse the process to de-serialize.
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:25**********************************@microsof t.com...
> Hello All,
>
> I want to serialize a hashtable to a database table to persist its
> values
> between postbacks. The client requires that I not use ViewState, hence
> the
> database.
>
> The samples in MSDN show how to serialize a class that implements the
> ICollection interface to a file. Does anyone know how to serialize to
> a
> database table and conversely de-serialize from the table?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: John Smith | last post by:
Hi, I am using a custom Session Handler. session_set_save_handler is working well. But i want to read the data direct from the database. My problem: php don't uses the standard serialize...
6
by: PawelR | last post by:
Hello group, I have irrational idea but I thing that this solution is good for me. In my apps I have custom class MyClass with few public, and private integers, two ArrayList etc. How serialize...
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
5
by: Brad | last post by:
I would like to serialize an arraylist of objects to xml so I can store the xml in a database column. How would I code the serializing and deserializing? Below is a (overly) simple, incomplete...
0
by: John Manion via .NET 247 | last post by:
Long Post, thanks for your patience... I have and XML file that looks something like this: <?xml version="1.0" encoding="utf-8" ?> <Settings> <Location> <X>30</X> <Y>40</Y> </Location>...
10
by: Rafi B. | last post by:
I'm running this on a Linux/CentOs/cPanel server, trying to add caching to my PHP5 code, using ADOdb. I have two Linux servers, one of them is running perfect, the second one, just crashes without...
1
by: js | last post by:
Does anybody knows how to solve the problem? I added attribute to the following classes in Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get the error. Thanks. ...
1
by: VooDoo | last post by:
Hi, I am using the serialize and unserialize to put and get data from mysql database. I think i could optimise the way i handle the data, but not really sure how. What is the best way to happend...
8
by: Andy B | last post by:
I have the following code in a default.aspx web form page_load event. There seems to be a problem with line 5 (NewsArticle.Date = line). //create a news article NewsArticle NewsArticle = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.