how to read/write properties to xml file for later retrieval?

I want to save my class property data into an xml file for later use i

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 9270 Views - Last Post: 09 September 2009 - 11:07 PM Rate Topic: -----

#16 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 08 September 2009 - 08:24 PM

Ok, so far this project is coming along nicely however I have run into a slight issue. I can get my dataset to write to an xml file just fine which is exactly what I wanted, however I am having an issue with my data being replicated in the dataset and repeated. For example I enter in different data in the first two account fields and click save and my data from the first field gets copied to all subsequent fields in the form and the dataset which then gets written to the xml file. I am trying to figure out where my coding is wrong here, and am having some trouble finding my error. It's probably something I'm overlooking. Any help would be greatly appreciated.

Here is my code:
Imports System.Windows.Forms
Imports System.IO

Public Class SetupMonthly

	Public Sub SaveXmlFile()
		Dim myStream As Stream
		Dim SaveFileDialog1 As New SaveFileDialog()

		SaveFileDialog1.Filter = "Xml Files (*.xml)|*.xml|All files (*.*)|*.*"
		SaveFileDialog1.FilterIndex = 1
		SaveFileDialog1.RestoreDirectory = True
		SaveFileDialog1.DefaultExt = "xml"

		If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
			myStream = SaveFileDialog1.OpenFile()
			If (myStream IsNot Nothing) Then
				EnvDataSet.PayType_Table1.WriteXml(myStream)
				EnvDataSet.Accounts_Table1.WriteXml(myStream)
				myStream.Close()
			End If
		End If

	End Sub

	Public Sub UpdateMonthDataSet()

		' Create New Pay Type Table Row
		Dim newPayTypeRow As EnvDataSet.PayType_Table1Row
		newPayTypeRow = EnvDataSet.PayType_Table1.NewPayType_Table1Row

		' Populate the New Pay Type Table Row with the User Data
		newPayTypeRow.PPMonthly = True
		newPayTypeRow.PPBiWeekly = False
		newPayTypeRow.PPLump = False
		newPayTypeRow.PPWeekly = False
		newPayTypeRow.PayMonthlyAmount = Txt_MPayAmt.Text
		newPayTypeRow.PayMonthlyBalance = RTxt_MBal.Text
		newPayTypeRow.UserName = Txt_UserName.Text
		EnvDataSet.PayType_Table1.Rows.Add(newPayTypeRow)

		' Populate the New Account Table Row with the User Data
		If (Txt_MName1.Text <> "") Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName1.Text
			newAccountRow.Amount = Txt_MAmt1.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName2.Text <> "" Then
			Dim newAccountRow2 As EnvDataSet.Accounts_Table1Row
			newAccountRow2 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow2.AccountName = Txt_MName2.Text
			newAccountRow2.Amount = Txt_MAmt2.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow2)
		End If
		If Txt_MName3.Text <> "" Then
			Dim newAccountRow3 As EnvDataSet.Accounts_Table1Row
			newAccountRow3 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow3.AccountName = Txt_MName3.Text
			newAccountRow3.Amount = Txt_MAmt3.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow3)
		End If
		If Txt_MName4.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName4.Text
			newAccountRow.Amount = Txt_MAmt4.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName5.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName5.Text
			newAccountRow.Amount = Txt_MAmt5.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName6.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName6.Text
			newAccountRow.Amount = Txt_MAmt6.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName7.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName7.Text
			newAccountRow.Amount = Txt_MAmt7.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName8.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName8.Text
			newAccountRow.Amount = Txt_MAmt8.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName9.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName9.Text
			newAccountRow.Amount = Txt_MAmt9.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName10.Text <> "" Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName10.Text
			newAccountRow.Amount = Txt_MAmt10.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
	End Sub

	Private MonthlyBudget As New EnvelopeSystem

	Private Sub PropogateMonthlyProperties()
		MonthlyBudget.PayMonthly = Txt_MPayAmt.Text
		MonthlyBudget.EnvName1 = Txt_MName1.Text
		MonthlyBudget.EnvName2 = Txt_MName2.Text
		MonthlyBudget.EnvName3 = Txt_MName3.Text
		MonthlyBudget.EnvName4 = Txt_MName4.Text
		MonthlyBudget.EnvName5 = Txt_MName5.Text
		MonthlyBudget.EnvName6 = Txt_MName6.Text
		MonthlyBudget.EnvName7 = Txt_MName7.Text
		MonthlyBudget.EnvName8 = Txt_MName8.Text
		MonthlyBudget.EnvName9 = Txt_MName9.Text
		MonthlyBudget.EnvName10 = Txt_MName10.Text
		MonthlyBudget.EnvAmount1 = Txt_MAmt1.Text
		MonthlyBudget.EnvAmount2 = Txt_MAmt2.Text
		MonthlyBudget.EnvAmount3 = Txt_MAmt3.Text
		MonthlyBudget.EnvAmount4 = Txt_MAmt4.Text
		MonthlyBudget.EnvAmount5 = Txt_MAmt5.Text
		MonthlyBudget.EnvAmount6 = Txt_MAmt6.Text
		MonthlyBudget.EnvAmount7 = Txt_MAmt7.Text
		MonthlyBudget.EnvAmount8 = Txt_MAmt8.Text
		MonthlyBudget.EnvAmount9 = Txt_MAmt9.Text
		MonthlyBudget.EnvAmount10 = Txt_MAmt10.Text
		MonthlyBudget.CalcMonthyBal()
		RTxt_MBal.Text = MonthlyBudget.MonthlyBal
	End Sub


	Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonNext.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.Close()
	End Sub

	Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.Close()
		Start.Visible = True
	End Sub

	Private Sub SetupMonthly_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub Btn_MonBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonBack.Click
		Me.Visible = False
		Start.Visible = True
	End Sub

	Private Sub NextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextToolStripMenuItem.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.Close()
	End Sub

	Private Sub CancelToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelToolStripMenuItem.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.Close()
		Start.Visible = True
	End Sub

	Private Sub BackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackToolStripMenuItem.Click
		Me.Visible = False
		Start.Visible = True
	End Sub

	Private Sub Btn_CalMonBal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_CalMonBal.Click
		PropogateMonthlyProperties()

	End Sub

	Private Sub Btn_MonSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonSave.Click
		UpdateMonthDataSet()
		SaveXmlFile()

	End Sub
End Class

Perhaps I am messing things up with my IF...THEN conditions? I am trying to check for empty fields and only create a new row in the dataset and write xml for the fields that are filled in by the user. Perhaps I am going about this wrong in my coding. Any tips would be appreciated.

I thought the issue may have been with my variables, so I changed the first three. This didn't seem to fix the issue so I left the coding until I find out where my error is.
Was This Post Helpful? 0
  • +
  • -

#17 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how to read/write properties to xml file for later retrieval?

Posted 08 September 2009 - 11:28 PM

Hi,

In these lines of code

 If (Txt_MName1.Text <> "") Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName1.Text
			newAccountRow.Amount = Txt_MAmt1.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)
		End If
		If Txt_MName2.Text <> "" Then
			Dim newAccountRow2 As EnvDataSet.Accounts_Table1Row
			newAccountRow2 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow2.AccountName = Txt_MName2.Text
			newAccountRow2.Amount = Txt_MAmt2.Text
			EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow2)
		End If

'ect..........



what dou you want to do with the txt_mName1.text?
if the text is not blank, add a row right?
so the code continues,
if the txt_MName2.text is not blank, add a new row.....
Is that correct?

Also your savexml sub writes twice to xml,

why not use
EnvDataSet.WriteXml(myStream)


Was This Post Helpful? 0
  • +
  • -

#18 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 09 September 2009 - 06:55 AM

You are correct Motcom on the IF ... Then statements they are only supposed to create a new row if the textboxes are not blank. My feeling is that somewhere in that section of code is where my data is getting replicated. Perhaps I am not implementing the New DataRow method correctly? I'm at a loss as to where the data is getting replicated.

I will use your suggestion and write the whole dataset once to xml rather than each table. This should make the xml look better also.
Was This Post Helpful? 0
  • +
  • -

#19 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how to read/write properties to xml file for later retrieval?

Posted 09 September 2009 - 07:41 AM

Hey,

I think i found it

This line
"newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row" already adds a line
so you do not need to to this
"EnvDataSet.Accounts_Table1.Rows.Add(newAccountRow)"

try this instead
(I presume you have a "Me.Accounts_Table1BindingSource"
in any case the bindingsource.endedit needs to be called to accept the new rows changes)

If (Txt_MName1.Text <> "") Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName1.Text
			newAccountRow.Amount = Txt_MAmt1.Text
			Me.Validate
			Me.Accounts_Table1BindingSource.EndEdit()
		End If




if that does not work, try the following
If (Txt_MName1.Text <> "") Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName1.Text
			newAccountRow.Amount = Txt_MAmt1.Text
			Me.Validate
			Me.Accounts_Table1BindingSource.EndEdit()
			EnvDataSet.AcceptChanges()
		End If


Was This Post Helpful? 0
  • +
  • -

#20 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 09 September 2009 - 08:41 AM

Thanks Motcom I will give each of those suggestions a try. I'll post my results as soon as I implement them. As I said before I knew something wasn't right with my implementation of the dataset methods and I do not know enough yet to see my own mistakes very clearly.
Was This Post Helpful? 0
  • +
  • -

#21 adam p  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-August 09

Re: how to read/write properties to xml file for later retrieval?

Posted 09 September 2009 - 09:07 AM

Well your code suggestion fixed the data replication in the dataset however it appears when I changed my SaveXml() method it no longer writes the account table data to the xml file.

here is a screenshot of the data entered onto the form after the save and it has not replicated as before which is good.

Attached Image

Here is my whole code:
Imports System.Windows.Forms
Imports System.IO

Public Class SetupMonthly

	Public Sub SaveXmlFile()
		Dim myStream As Stream
		Dim SaveFileDialog1 As New SaveFileDialog()

		SaveFileDialog1.Filter = "Xml Files (*.xml)|*.xml|All files (*.*)|*.*"
		SaveFileDialog1.FilterIndex = 1
		SaveFileDialog1.RestoreDirectory = True
		SaveFileDialog1.DefaultExt = "xml"

		If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
			myStream = SaveFileDialog1.OpenFile()
			If (myStream IsNot Nothing) Then
				EnvDataSet.WriteXml(myStream)
				myStream.Close()
			End If
		End If

	End Sub

	Public Sub UpdateMonthDataSet()

		' Create New Pay Type Table Row
		Dim newPayTypeRow As EnvDataSet.PayType_Table1Row
		newPayTypeRow = EnvDataSet.PayType_Table1.NewPayType_Table1Row

		' Populate the New Pay Type Table Row with the User Data
		newPayTypeRow.PPMonthly = True
		newPayTypeRow.PPBiWeekly = False
		newPayTypeRow.PPLump = False
		newPayTypeRow.PPWeekly = False
		newPayTypeRow.PayMonthlyAmount = Txt_MPayAmt.Text
		newPayTypeRow.PayMonthlyBalance = RTxt_MBal.Text
		newPayTypeRow.UserName = Txt_UserName.Text
		EnvDataSet.PayType_Table1.Rows.Add(newPayTypeRow)

		' Populate the New Account Table Row with the User Data
		If (Txt_MName1.Text <> "") Then
			Dim newAccountRow As EnvDataSet.Accounts_Table1Row
			newAccountRow = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow.AccountName = Txt_MName1.Text
			newAccountRow.Amount = Txt_MAmt1.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName2.Text <> "" Then
			Dim newAccountRow2 As EnvDataSet.Accounts_Table1Row
			newAccountRow2 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow2.AccountName = Txt_MName2.Text
			newAccountRow2.Amount = Txt_MAmt2.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName3.Text <> "" Then
			Dim newAccountRow3 As EnvDataSet.Accounts_Table1Row
			newAccountRow3 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow3.AccountName = Txt_MName3.Text
			newAccountRow3.Amount = Txt_MAmt3.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName4.Text <> "" Then
			Dim newAccountRow4 As EnvDataSet.Accounts_Table1Row
			newAccountRow4 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow4.AccountName = Txt_MName4.Text
			newAccountRow4.Amount = Txt_MAmt4.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName5.Text <> "" Then
			Dim newAccountRow5 As EnvDataSet.Accounts_Table1Row
			newAccountRow5 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow5.AccountName = Txt_MName5.Text
			newAccountRow5.Amount = Txt_MAmt5.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName6.Text <> "" Then
			Dim newAccountRow6 As EnvDataSet.Accounts_Table1Row
			newAccountRow6 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow6.AccountName = Txt_MName6.Text
			newAccountRow6.Amount = Txt_MAmt6.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName7.Text <> "" Then
			Dim newAccountRow7 As EnvDataSet.Accounts_Table1Row
			newAccountRow7 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow7.AccountName = Txt_MName7.Text
			newAccountRow7.Amount = Txt_MAmt7.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName8.Text <> "" Then
			Dim newAccountRow8 As EnvDataSet.Accounts_Table1Row
			newAccountRow8 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow8.AccountName = Txt_MName8.Text
			newAccountRow8.Amount = Txt_MAmt8.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName9.Text <> "" Then
			Dim newAccountRow9 As EnvDataSet.Accounts_Table1Row
			newAccountRow9 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow9.AccountName = Txt_MName9.Text
			newAccountRow9.Amount = Txt_MAmt9.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
		If Txt_MName10.Text <> "" Then
			Dim newAccountRow10 As EnvDataSet.Accounts_Table1Row
			newAccountRow10 = EnvDataSet.Accounts_Table1.NewAccounts_Table1Row
			newAccountRow10.AccountName = Txt_MName10.Text
			newAccountRow10.Amount = Txt_MAmt10.Text
			Me.Validate()
			Me.AccountsTable1BindingSource.EndEdit()
		End If
	End Sub

	Private MonthlyBudget As New EnvelopeSystem

	Private Sub PropogateMonthlyProperties()
		MonthlyBudget.PayMonthly = Txt_MPayAmt.Text
		MonthlyBudget.EnvName1 = Txt_MName1.Text
		MonthlyBudget.EnvName2 = Txt_MName2.Text
		MonthlyBudget.EnvName3 = Txt_MName3.Text
		MonthlyBudget.EnvName4 = Txt_MName4.Text
		MonthlyBudget.EnvName5 = Txt_MName5.Text
		MonthlyBudget.EnvName6 = Txt_MName6.Text
		MonthlyBudget.EnvName7 = Txt_MName7.Text
		MonthlyBudget.EnvName8 = Txt_MName8.Text
		MonthlyBudget.EnvName9 = Txt_MName9.Text
		MonthlyBudget.EnvName10 = Txt_MName10.Text
		MonthlyBudget.EnvAmount1 = Txt_MAmt1.Text
		MonthlyBudget.EnvAmount2 = Txt_MAmt2.Text
		MonthlyBudget.EnvAmount3 = Txt_MAmt3.Text
		MonthlyBudget.EnvAmount4 = Txt_MAmt4.Text
		MonthlyBudget.EnvAmount5 = Txt_MAmt5.Text
		MonthlyBudget.EnvAmount6 = Txt_MAmt6.Text
		MonthlyBudget.EnvAmount7 = Txt_MAmt7.Text
		MonthlyBudget.EnvAmount8 = Txt_MAmt8.Text
		MonthlyBudget.EnvAmount9 = Txt_MAmt9.Text
		MonthlyBudget.EnvAmount10 = Txt_MAmt10.Text
		MonthlyBudget.CalcMonthyBal()
		RTxt_MBal.Text = MonthlyBudget.MonthlyBal
	End Sub


	Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonNext.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.Close()
	End Sub

	Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.Close()
		Start.Visible = True
	End Sub

	Private Sub SetupMonthly_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub Btn_MonBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonBack.Click
		Me.Visible = False
		Start.Visible = True
	End Sub

	Private Sub NextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextToolStripMenuItem.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.OK
		Me.Close()
	End Sub

	Private Sub CancelToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelToolStripMenuItem.Click
		Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
		Me.Close()
		Start.Visible = True
	End Sub

	Private Sub BackToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackToolStripMenuItem.Click
		Me.Visible = False
		Start.Visible = True
	End Sub

	Private Sub Btn_CalMonBal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_CalMonBal.Click
		PropogateMonthlyProperties()

	End Sub

	Private Sub Btn_MonSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_MonSave.Click
		UpdateMonthDataSet()
		SaveXmlFile()

	End Sub
End Class


And here is my finished xml file which is missing the accounts table data:
<EnvDataSet xmlns="http://tempuri.org/EnvDataSet.xsd">
  <PayType_x0020_Table1>
	<PayTypeID>1</PayTypeID>
	<PPMonthly>true</PPMonthly>
	<PPBiWeekly>false</PPBiWeekly>
	<PPWeekly>false</PPWeekly>
	<PPLump>false</PPLump>
	<PayMonthlyAmount>2500.25</PayMonthlyAmount>
	<PayMonthlyBalance>1539.75</PayMonthlyBalance>
	<UserName>John Doe</UserName>
  </PayType_x0020_Table1>
</EnvDataSet>


Edit: I tried replacing the old writxml coding and that changed nothing. somehow with both of those suggestions my accounts table is not getting updated with the new rows from the form. I am going to do more research on the dataset class and it's methods in order to completely understand what is/isn't going on here.

This post has been edited by adam p: 09 September 2009 - 08:56 PM

Was This Post Helpful? 0
  • +
  • -

#22 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: how to read/write properties to xml file for later retrieval?

Posted 09 September 2009 - 11:07 PM

its worthwhile looking into them.
When you get used to them, linking to databases in a later stage will be easy, and its less code.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2