|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can I write and read a STRUCTURE to a file or to a Database???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 ---------------------------------------------------------------------------------------------------------- Hello Hexman,
Sure. Check out the various serialization mechanisims in .NET. Fuirst one that comes to mind is System.Xml.Serialization.XmlSerializer -Boo Show quoteHide quote > 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 > > ---------------------------------------------------------------------- > ------------------------------------ > Thanks, I'll check into it.
On Thu, 13 Jul 2006 06:06:16 +0000 (UTC), GhostInAK <ghosti***@gmail.com> wrote: Show quoteHide quote >Hello Hexman, > >Sure. Check out the various serialization mechanisims in .NET. Fuirst one >that comes to mind is System.Xml.Serialization.XmlSerializer > >-Boo > >> 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 >> >> ---------------------------------------------------------------------- >> ------------------------------------ >> >
Reading one record from an Access DB
dataser design considerations converting short to unicode without System.Text.UnicodeEncoding ?Delegates and Interaces - similarities/differences? Mdi Form Validating VB.NET ComboBox _SelectedIndexChanged checking MP3 license Treeview problem How to find files in a directory ComboBox in DataGrid |
|||||||||||||||||||||||