serialization?

jfackler

Well-known member
Joined
Mar 15, 2003
Messages
393
Location
Cincinnati, Ohio
User Rank
*Experts*
I have an array of datarows that I would like to save and recall.
I am using a ms access db for my data, and have tried to serialize the array (a selection of datarows selected from a table of employees holding comments along with nominations for the employee of the month) with no success.
I cant seem to wrap my head around a solution, or my solutions are not working.
Any suggestions would be greatly appreciated.
Code:
areomcomment = Me.dataset1.Tables("Employees").Select("EOMNom = " & EOM & "")
Dim bif As System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            Dim fis As New FileStream("C:\Program Files\Payroll\eomcomment.text", FileMode.Create)
            bif.Serialize(fis, areomcomment)
            fis.Close()

I am not getting an error with the above solution, however, I am also not saving the datarows either.

Jon
 
It looks like you didnt instantiate a BinaryFormatter object (which seems odd that it wouldnt give you an error for that). You should probably also create a FileStreamingContext "just in case."

Code:
areomcomment = Me.dataset1.Tables("Employees").Select("EOMNom = " & EOM & "")
Dim context As New StreamingContext(StreamingContexts.File)
Dim bif As New BinaryFormatter(Nothing, context)
Dim fis As New FileStream("C:\Program Files\Payroll\eomcomment.text", FileMode.Create)
bif.Serialize(fis, areomcomment)
fis.Close()
 
Thanks Wyrd,
Ive pursued another solution that is working great. I will try the
serialization solution you suggested, I dont have any experience
with the concept so...now I have a chance to further my knowledge. Ah.... those growth opportunities.
By the way, I checked out your web page link. Keep up the good
work.

Jon
 
I should give you a short answer but Im in a verbose mood.
The program is designed for my employees to enter their clock-in
and clock-out times. It calculates overtime, tracks paid time-off
(PTO, our equivalent to sick and personal time), calculates
remaining PTO, archives the past pay periods and allows the
person writing payroll checks the ability to review past pay-periods.
We decided to incorporate an Empoyee of the Month(EOM) into the office culture and to reward
an Employee of the Quarter with a nice reward (this quarter is a DVD/VCR player).
Each employee now has to nominate an EOM each pay-period.
Ive reworked the payroll program to track the nominations and save a comment
for each nomination, the program wont let them submit their hours
for payroll until they have nominated someone for EOM. Im using
Access as a db just because its cheap, easy and my partner can
understand what Im doing if I use it. Also, we dont have multiple
simultaneous hits or a very large database.
Now the part I asked about....
I wanted to display the winner of EOM each time an employee signed
on the the payroll system. I also wanted to randomly select one
of the nomination comments with that window displaying the EOM.
The easy solution was to simply persist up to 10 of the comments
to the database and randomly select a comment at each pop-up
of the splash that congratulates/announces the EOM.
Small over head and little needed from my head to get it done.

So, long answer, simple solution, simple minds, etc.

Jon
 
Back
Top