473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.Wr ite(TR)

or

Dim dtTrans As New DataTable
Dim drTrans as New DataRow

dtTrans(0) = TR
----------------------------------------------------------------------------------------------------------
Jul 13 '06 #1
2 1143
Hello Hexman,

Sure. Check out the various serialization mechanisims in .NET. Fuirst one
that comes to mind is System.Xml.Seri alization.XmlSe rializer

-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.Wr ite(TR)

or

Dim dtTrans As New DataTable
Dim drTrans as New DataRow
dtTrans(0) = TR

----------------------------------------------------------------------
------------------------------------

Jul 13 '06 #2
Thanks, I'll check into it.

On Thu, 13 Jul 2006 06:06:16 +0000 (UTC), GhostInAK <gh*******@gmai l.comwrote:
>Hello Hexman,

Sure. Check out the various serialization mechanisims in .NET. Fuirst one
that comes to mind is System.Xml.Seri alization.XmlSe rializer

-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.W rite(TR)

or

Dim dtTrans As New DataTable
Dim drTrans as New DataRow
dtTrans(0) = TR

----------------------------------------------------------------------
------------------------------------
Jul 13 '06 #3

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

Similar topics

3
4602
by: Michael Van Altena via .NET 247 | last post by:
I'm trying to figure out how to read a formatted binary file intoa structure definition in C#. I've tried using the"StructLayout" attribute with both LayoutKind.Explicit andLayoutKind.Sequential options. I can get this to worksuccessfully, but only when I'm NOT dealing with arrays in thestructure definition. For example: In C, you are able to simply read a binary file intoa structure as follows: ...
18
4876
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
2
1037
by: Simon Mayr | last post by:
Hi. I'm new to XML and have a big problem. I should write a program that can show any XML-File in a TreeView. Thats no problem. Furthermore I should be able to change any entry in the Treeview and write the changes back into the XML-File. And thats the problem. It would be easy if I would know the structure of the XML-File but as i said the program should be able to edit any XML-File. I found out that the XmlTextReader has ..Depth,...
4
1932
by: marcmc | last post by:
Hi, I hope to create a XML file that will hold my Connection data to a SQL Db. I want to write an XML file from 4 Text Box named UserName, Password, Database & Server and later read from it. My XMLSchema elements are named dbLogin, dbPassword, dbDatabase & dbServer I receive a 'System.NullReferenceException Info: Object refernece not set to an instance of an object' on the following line of code: dtSettings = Settings.Tables("Settings")...
8
23899
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
2
3685
by: Tiger | last post by:
I try to write a struct into a brut file but I can't write all var in this struct when I try to add user I have that : > testmachine:/usr/share/my_passwd# ./my_passwd -a users.db > Ajout d'une entrée dans la base : > > Username : test > Password : aze > Gecos : qsd
6
1850
by: bill | last post by:
All, I have an unmanaged data structure that I use to pass to an umanaged DLL written in C. This works great. The structure looks sort of like this: unsafe public struct Inputs { .....
5
2634
by: active | last post by:
RecIn is a structure FileGet(FileNum, RecIn, mNumb) works if I have Option Strict Off File was written by
6
7059
by: Per Juul Larsen | last post by:
Hi. My Textfile looks like this Variable 1 Variable 2 Variable 3 Variable 4 On opening the application it will read the textfile, and assign each line of variable to at textfield in VB and then close the file.
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.