Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vb.net save data/ load data

Status
Not open for further replies.

Bvisual

Programmer
Jul 1, 2005
35
BE
I am creating a program that has 9 diffrent users.
the meaning of the program is that each user can select some products. The select product wil then be saved in a datagrid.

example:
User 1 User2 User3 ... ...
product1 1 2 2
product2 2 1 ...
product3 3 0
product4 8 0
product5 2 2


now the problem is the data has to be saved so when the pc turnes of or on an error accures the data save to the backup file the data wil be resettet into the datafield.

i would like to make this work whit a exel or acces file

could someone help me do this

thx
 
I really don't understand what you are trying to do here. You say that the "product wil then be saved in a datagrid." A datagrid is simply a visual representation of some data (usually a dataset, datatable, etc), you don't save something to a datagrid.

When you say "the data has to be saved so when the pc turnes of or on" do you mean that the user will simply turn off the computer without saving the data first? If this is the case then you will need to do automatic backups at intervals, or some other method, or simply store the changes automatically.

I really just don't understand this sentence..."now the problem is the data has to be saved so when the pc turnes of or on an error accures the data save to the backup file the data wil be resettet into the datafield."

I guess I'm asking for a little clarification here.
 
i put data from a array in a datagrid for visual control.

But the data in the array has to be saved (on change) to a file outside vb.net.

On load of the main form i will check if the file is empty with will mean that the pc is turned off whit saving the data.
But when the file is not empty the data from the file whil be loaded in the array and then for visual control in the datagrid.

I hope its clear for you.


? how do you creat, read and write to a XML file ?
a code example would be easy

thx
 
create a data table, populate it, then use the data set.WriteXML and .ReadXML.

Code:
'create and populate a data table
dim dt as new datatable
dim dc as datacolumn
dim dr as datarow

dc=new datacolumn("Field1", gettype(integer))
dt.columns.add(dc)
dc=new datacolumn("Field2", gettype(string))
dt.columns.add(dc)

dr = dt.newrow
dr.item("Field1") = 0
dr.item("Field2") = "A value!"
dt.rows.add(dr)

dr = dt.newrow
dr.item("Field1") = 1
dr.item("Field2") = "Another value!"
dt.rows.add(dr)

'display the data in a data grid:
Datagrid.datasource = dt


'save the data
public sub Save()
  dt.dataset.writexml("FileName.xml", XmlWriteMode.WriteSchema)
end sub

'load the data
public sub Load()
  dt.dataset.readxml("FileName.xml")
end sub

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top