Click here to Skip to main content
12,290,956 members (68,066 online)

.NET Framework

 
AnswerRe: Adding a flash webcam photo capture Pin
Eddy Vluggen18-Dec-12 2:01
memberEddy Vluggen18-Dec-12 2:01 
GeneralRe: Adding a flash webcam photo capture Pin
lhsunshine18-Dec-12 18:03
memberlhsunshine18-Dec-12 18:03 
GeneralRe: Adding a flash webcam photo capture Pin
lhsunshine18-Dec-12 19:18
memberlhsunshine18-Dec-12 19:18 
GeneralRe: Adding a flash webcam photo capture Pin
Eddy Vluggen18-Dec-12 20:40
memberEddy Vluggen18-Dec-12 20:40 
GeneralRe: Adding a flash webcam photo capture Pin
lhsunshine19-Dec-12 2:28
memberlhsunshine19-Dec-12 2:28 
QuestionSplitting a url Pin
El daniel14-Dec-12 22:02
memberEl daniel14-Dec-12 22:02 
Questionpulling across value from list to display in view Pin
xnaLearner14-Dec-12 5:58
memberxnaLearner14-Dec-12 5:58 
AnswerRe: pulling across value from list to display in view Pin
xnaLearner14-Dec-12 6:49
memberxnaLearner14-Dec-12 6:49 
AnswerRe: pulling across value from list to display in view Pin
frazzle-me14-Dec-12 17:41
memberfrazzle-me14-Dec-12 17:41 
GeneralRe: pulling across value from list to display in view Pin
xnaLearner15-Dec-12 8:28
memberxnaLearner15-Dec-12 8:28 
Questionproblem with relationships Pin
xnaLearner13-Dec-12 2:45
memberxnaLearner13-Dec-12 2:45 
AnswerRe: problem with relationships Pin
Richard Deeming13-Dec-12 3:48
memberRichard Deeming13-Dec-12 3:48 
GeneralRe: problem with relationships Pin
xnaLearner13-Dec-12 4:37
memberxnaLearner13-Dec-12 4:37 
Question[VB.NET 2008] DataSet and XML files Pin
steve_949661313-Dec-12 0:06
membersteve_949661313-Dec-12 0:06 
Hi,
in my application (running in Windows CE) I use a XML file to store some configuration data that, at runtime, I load in a DataSet.
To read and to store these data I use the following code:
Private Shared Function SetCfgData() As Boolean
 
   Try
     Dim fs As New FileStream(CGlobali.CfgDataFileComplName, FileMode.Open)
     Dim xr As XmlReader = System.Xml.XmlReader.Create(fs)
 
     'CGlobali.CfgData is a DataSet
     CGlobali.CfgData.Clear()
     CGlobali.CfgData.ReadXml(xr)
 
     xr.Close()
     fs.Close()
 
   Catch ex As System.IO.FileNotFoundException
     MessageBox.Show("File " & CGlobali.CfgDataFileComplName & " not found.")
     Return False
   Catch ex As XmlException
     MessageBox.Show("XmlException occured: " & ex.ToString)
     Return False
   End Try
 
   Return True
When the user modifies these data, they are automatically updated in the DataSet and saved in the file, at least that's what I would do...

To save the data from the DataSet to the file I do this:
Private Shared Function UpdateCgfFile() As Boolean
 
  Try
    Dim StreamEncoding As Encoding
    StreamEncoding = Encoding.Unicode
    Dim cfgfile As New System.IO.StreamWriter(CGlobali.CfgDataFileComplName, True, StreamEncoding)
 
    CGlobali.CfgData.WriteXml(cfgfile)
 
    cfgfile.Close()
 
    Return True
  Catch ex As Exception
    Return False
  End Try
End Function
What I would get with the above code is to update existing fields in the xml file with the new values, but what I get is that the same fields are added to the existing ones.

This is the "original" file:
<?xml version="1.0" encoding="UTF-16"?>
<Sezioni>
  <PLC>
    <IP>10.0.0.85</IP>
    <Port>502</Port>
    <Description></Description>
    <PauComm>15000</PauComm>
    <ConTOut>5000</ConTOut>
    <RxTOut>5000</RxTOut>
  </PLC>
</Sezioni>

and this is the file after a save:
<?xml version="1.0" encoding="UTF-16"?>
<Sezioni>
  <PLC>
    <IP>10.0.0.85</IP>
    <Port>502</Port>
    <Description></Description>
    <PauComm>15000</PauComm>
    <ConTOut>5000</ConTOut>
    <RxTOut>5000</RxTOut>
  </PLC>
</Sezioni>
<Sezioni>
  <PLC>
    <IP>192.168.1.10</IP>
    <Port>502</Port>
    <Description />
    <PauComm>15000</PauComm>
    <ConTOut>5000</ConTOut>
    <RxTOut>5000</RxTOut>
  </PLC>
</Sezioni>
Obviously this is not the result I want to achieve, I do not want to duplicate fields, I want to update the existing ones.

Can someone tell me what I'm doing wrong?

Thanks in advance.
AnswerRe: [VB.NET 2008] DataSet and XML files Pin
Eddy Vluggen13-Dec-12 4:28
memberEddy Vluggen13-Dec-12 4:28 
GeneralRe: [VB.NET 2008] DataSet and XML files Pin
steve_949661313-Dec-12 21:21
membersteve_949661313-Dec-12 21:21 
GeneralRe: [VB.NET 2008] DataSet and XML files Pin
Eddy Vluggen14-Dec-12 0:34
memberEddy Vluggen14-Dec-12 0:34 
QuestionAssembly with different .NET framework versions Pin
marca29212-Dec-12 10:05
membermarca29212-Dec-12 10:05 
AnswerRe: Assembly with different .NET framework versions Pin
Gerry Schmitz12-Dec-12 12:25
memberGerry Schmitz12-Dec-12 12:25 
QuestionUse A Cookie To Send PersonID To Different Page Pin
xnaLearner12-Dec-12 4:33
memberxnaLearner12-Dec-12 4:33 
Questiondont allow user to select existing date Pin
xnaLearner10-Dec-12 5:46
memberxnaLearner10-Dec-12 5:46 
AnswerRe: dont allow user to select existing date Pin
Pete O'Hanlon10-Dec-12 5:53
protectorPete O'Hanlon10-Dec-12 5:53 
GeneralRe: dont allow user to select existing date Pin
xnaLearner10-Dec-12 6:23
memberxnaLearner10-Dec-12 6:23 
GeneralRe: dont allow user to select existing date Pin
xnaLearner10-Dec-12 23:26
memberxnaLearner10-Dec-12 23:26 
GeneralRe: dont allow user to select existing date Pin
Pete O'Hanlon10-Dec-12 23:32
protectorPete O'Hanlon10-Dec-12 23:32 
GeneralRe: dont allow user to select existing date Pin
xnaLearner10-Dec-12 23:46
memberxnaLearner10-Dec-12 23:46 
GeneralRe: dont allow user to select existing date Pin
Pete O'Hanlon10-Dec-12 23:51
protectorPete O'Hanlon10-Dec-12 23:51 
GeneralRe: dont allow user to select existing date Pin
xnaLearner11-Dec-12 0:21
memberxnaLearner11-Dec-12 0:21 
GeneralRe: dont allow user to select existing date Pin
Pete O'Hanlon11-Dec-12 1:02
protectorPete O'Hanlon11-Dec-12 1:02 
QuestionRun through loop for week and dont select weekends Pin
xnaLearner10-Dec-12 4:13
memberxnaLearner10-Dec-12 4:13 
AnswerRe: Run through loop for week and dont select weekends Pin
Pete O'Hanlon10-Dec-12 4:31
protectorPete O'Hanlon10-Dec-12 4:31 
GeneralRe: Run through loop for week and dont select weekends Pin
xnaLearner10-Dec-12 4:52
memberxnaLearner10-Dec-12 4:52 
GeneralRe: Run through loop for week and dont select weekends Pin
Pete O'Hanlon10-Dec-12 4:53
protectorPete O'Hanlon10-Dec-12 4:53 
QuestionDeploying a Windows Service Pin
indian14310-Dec-12 4:09
memberindian14310-Dec-12 4:09 
AnswerRe: Deploying a Windows Service Pin
Pete O'Hanlon10-Dec-12 5:04
protectorPete O'Hanlon10-Dec-12 5:04 
GeneralRe: Deploying a Windows Service Pin
indian14310-Dec-12 5:08
memberindian14310-Dec-12 5:08 
GeneralRe: Deploying a Windows Service Pin
Pete O'Hanlon10-Dec-12 5:20
protectorPete O'Hanlon10-Dec-12 5:20 
Questionrun through startDate to endDate and add each record to DB Pin
xnaLearner10-Dec-12 2:04
memberxnaLearner10-Dec-12 2:04 
AnswerRe: run through startDate to endDate and add each record to DB Pin
xnaLearner10-Dec-12 2:35
memberxnaLearner10-Dec-12 2:35 
QuestionASP.NET Post Textbox After Button Click Pin
xnaLearner9-Dec-12 11:15
memberxnaLearner9-Dec-12 11:15 
AnswerRe: ASP.NET Post Textbox After Button Click Pin
Richard MacCutchan9-Dec-12 21:54
mvpRichard MacCutchan9-Dec-12 21:54 
GeneralRe: ASP.NET Post Textbox After Button Click Pin
xnaLearner10-Dec-12 0:14
memberxnaLearner10-Dec-12 0:14 
Question.netframework Pin
zofi518-Dec-12 4:30
memberzofi518-Dec-12 4:30 
AnswerRe: .netframework Pin
Dave Kreskowiak8-Dec-12 6:37
mvpDave Kreskowiak8-Dec-12 6:37 
AnswerRe: .netframework Pin
Eddy Vluggen8-Dec-12 7:18
memberEddy Vluggen8-Dec-12 7:18 
GeneralRe: .netframework Pin
Kevin Bewley13-Jan-13 23:46
memberKevin Bewley13-Jan-13 23:46 
AnswerRe: .netframework Pin
jibesh11-Dec-12 10:36
memberjibesh11-Dec-12 10:36 
QuestionEnter 3 dates and display order in different VIEW, after click Pin
xnaLearner7-Dec-12 9:52
memberxnaLearner7-Dec-12 9:52 
Question[VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
steve_94966136-Dec-12 21:37
membersteve_94966136-Dec-12 21:37 
AnswerRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
Zaf Khan10-Dec-12 17:57
memberZaf Khan10-Dec-12 17:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160518.1 | Last Updated 24 May 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid