Can I write and read a STRUCTURE to a file or to a Database???

H

Hexman

Hi All,

I have created a structure for a record (as I did in the old days with assembler, cobol, etc.). It contains several fields with various types. Using
it in arrays it functions nicely. Much the same as a datarow. I'm acquiring transactions from different sources, parsing them, validating them and
placing the data into the structure. Now, I want to write these transactions to a file.

How do I write the entire structure (one entry) to a streamwriter??? Is it possible to create a datatable with the same fields and structure and add
a row with one statement (moving the structure to the datarow)???

Just trying to organize a bit better and have flexibility (write to db or file).

Thanks,

Hexman


-----------------------------------------------------------------------------------------------------
Public Structure TransRecord
Dim TDate As Date
Dim TPONum As String
Dim TAmt As Double
End Structure
....

Dim TR as New TransRecord

TR.TDate = "06/12/06"
TR.TPONum = "12345-A"
TR.TAmt = 1450.25

Can I do something like the following?

streamWriter.Write(TR)

or

Dim dtTrans As New DataTable
Dim drTrans as New DataRow

dtTrans(0) = TR


----------------------------------------------------------------------------------------------------------
 
G

GhostInAK

Hello Hexman,

Sure. Check out the various serialization mechanisims in .NET. Fuirst one
that comes to mind is System.Xml.Serialization.XmlSerializer

-Boo
 
H

Hexman

Thanks, I'll check into it.

Hello Hexman,

Sure. Check out the various serialization mechanisims in .NET. Fuirst one
that comes to mind is System.Xml.Serialization.XmlSerializer

-Boo
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top