Solved

How to delete rows in xml files based on rows selected from a Grid?

Posted on 2011-02-24
2
499 Views
Last Modified: 2012-05-11
Hello,

How do I delete records in my Link.xml file when I delete a record from the grid control. For example if I select a row with Fuze_ID = 5, I would like to loop through my Link.xml file and delete all the records with Fuze_ID = 5.

I'm using the code code below, but I'm receiving the following error:
"Index 5 is either negative or above rows count"

On line: DV.Item(X).Delete()

Any ideas what's wrong with the code.

Thanks,

Victor

Dim dr As DataRow = dt.NewRow()    
dr("Link_ID") = linkID    
dr("Fuze_ID") = FuzeID    
dt.Rows.Add(dr)    
Next    
'Delete Selecete Record    
Dim X As Integer    
Dim DV As New DataView(dt, "Fuze_ID like " & "'" & C1TrueDBGrid.Columns(0).Value & "'" & "", Nothing, DataViewRowState.CurrentRows)    
 
For X = 0 To DV.Count - 1    
DV.Item(X).Delete()    
Next    
Dim DV1 As New DataView(dt, "", Nothing, DataViewRowState.CurrentRows)    
Dim FilteredDT As DataTable    
FilteredDT = DV1.ToTable    
'put data back to xml file    
FilteredDT.TableName = "Row"    
FilteredDT.WriteXml(Application.StartupPath + "\Link.xml")
0
Comment
Question by:vcharles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 500 total points
ID: 34976716
You are supposed to look for fuze id 5 but your code is deleting 5 th row
0
 

Author Closing Comment

by:vcharles
ID: 35047940
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Schema 6 45
VB.NET - Refactor Class per SOLID principles 2 33
Help with Progress 4gl Rounding Function 6 22
Error in sql query statment. 21 41
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question