473,320 Members | 2,020 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,320 software developers and data experts.

Persisting fixed data

I'm stretching my fairly elementary vb.net experience by trying to
write a report generator for a specialised utility. The report will
contain a simple tabular output, but there could be up to 100 or more
column types from which the user can choose to include on a specific
report and each type may have eg 10 attributes: name, value, width,
formatting etc etc

All the types and attributes are known at design time and could be
used to populate eg a structure array, though there obviously are
other alternatives.

But the question is about how best to persist this data. I don't
really want to assign the attributes one at a time, ie one line of
code per attribute, because that would create 1000 lines of code or
more and be pretty cumbersome to maintain. But equally it would be
nice to avoid a more structured solution such as eg an external
database that could bloat the program. In fact being able to embed the
data within the main assembly would seem to be a more elegant
solution, but I guess simplicity is more important than elegance.

Anyone have any advice please, bearing in mind that I'm not an expert
vb.net user.

Thanks
JGD
Nov 21 '05 #1
2 1046
If you create a class called "columntype", containing your attributes - you
can populate an array of column types and output them to an XML file with a
single loop. Simple example below, that doesn't fill in many of the blanks:
class myColumnType

private m_Name as String
private m_Value as Object
private m_Width as integer

public sub WriteXML (theNode as XmlNode)
...
... write my attributes to the xml tree
...
end sub

public sub ReadXML (theNode as XmlNode)
...
... read my attributes from the xml tree
...
end sub

end class
private m_Array as New ArrayList

m_Array.Add ( new MyColumnType ( bla bla bla ) )
m_Array.Add ( new MyColumnType ( foo foo foo ) )

for each theColumn as MyColumnType In m_Array
theColumn.WriteXML ( theXMLDocument)
Next
"John Dann" <ne**@prodata.co.uk> wrote in message
news:8i********************************@4ax.com...
I'm stretching my fairly elementary vb.net experience by trying to
write a report generator for a specialised utility. The report will
contain a simple tabular output, but there could be up to 100 or more
column types from which the user can choose to include on a specific
report and each type may have eg 10 attributes: name, value, width,
formatting etc etc

All the types and attributes are known at design time and could be
used to populate eg a structure array, though there obviously are
other alternatives.

But the question is about how best to persist this data. I don't
really want to assign the attributes one at a time, ie one line of
code per attribute, because that would create 1000 lines of code or
more and be pretty cumbersome to maintain. But equally it would be
nice to avoid a more structured solution such as eg an external
database that could bloat the program. In fact being able to embed the
data within the main assembly would seem to be a more elegant
solution, but I guess simplicity is more important than elegance.

Anyone have any advice please, bearing in mind that I'm not an expert
vb.net user.

Thanks
JGD

Nov 21 '05 #2
Serialize the data to a stream... the basics are pretty easy
0) decorate your class with <Serializable()>
1) create a stream: Dim fstream As New FileStream("MyFile.bin",
FileMode.Create, FileAccess.Write, FileShare.None)
2) create a formatter: Dim bf as New BinaryFormatter()
3) serialize: bf.Serialize(fstream,YourClass)
4) clean-up: fstream.Close()

there are some special consideration about the deserialization -- you
will need a special class constructor... the .NET Framework will
serialize an object graph (i.e. it will serialize objects within your
object).

here are some links -- the first has a demo...
Object Serialization in Visual Basic .NET (Adventures in .NET)
http://msdn.microsoft.com/library/en...asp?frame=true

Serializing Objects (.NET Framework Developer's Guide)
http://msdn.microsoft.com/library/en...asp?frame=true

good links to related topics here...
Binary Serialization (.NET Framework Developer's Guide)
http://msdn.microsoft.com/library/en...asp?frame=true

Nov 21 '05 #3

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

Similar topics

2
by: Chris S. | last post by:
Out of a somewhat academic interest, I've created a rudimentary module for persisting dynamically created objects and data structures in plain Python source code. Presently, it's a little under a...
2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
3
by: Tom | last post by:
Hi, I am looking for an article or tutorial on persisting winform user input for the life of the app. How to design it? For instance, do I create a container class specific to each form? This...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
1
by: lim | last post by:
What is the possible error that occurs when the Page_load event is not triggered during execution. In my page there's some basic server control. Is there any loops holes?
2
by: John Hoge | last post by:
A common problem in database updates in the maintenece of "domain tables". For example, a product database has an option for color. When entering the specifications for a new product, a domain...
2
by: xenophon | last post by:
I added a Hidden Form Field to a form in the code behind. The value is being set in JavaScript client-side, but it is not persisting to the server in the PostBack. I know the value is being set...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
0
ADezii
by: ADezii | last post by:
Most Access Users realize that Recordsets, being virtual representations of a Query, Table, or SQL Statement, exist only in our PC's memory. They, and the data they contain, literally exist at one...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.