473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

removing rows from a table in a dataset

Can someone tell me what I may be doing wrong here...

I'm trying to remove rows from a table in a dataset that have the same data.
My code is pasted below.
The 2nd time it runs through the code, I get an error message "Deleted row
information cannot be accessed through the row" on the line 'drT2 =
ds.Tables(0).Rows(varI + 1)
'

How can I fix this??

Public Function removeDuplicateRowsDS(ByVal ds As DataSet, ByVal
strFieldName As String) As DataSet
'Removes duplicate rows from a dataset

Dim varI As Integer
Dim strTemp As String
Dim strTemp2 As String
Dim drT As DataRow
Dim drT2 As DataRow
Do While varI < (ds.Tables(0).Rows.Count) - 1
drT = ds.Tables(0).Rows(varI)
strTemp = drT(strFieldName).ToString
drT2 = ds.Tables(0).Rows(varI + 1)
strTemp2 = drT2(strFieldName).ToString

If strTemp = strTemp2 Then
ds.Tables(0).Rows(varI).Delete()
Else
varI = varI + 1
End If
Loop
Return ds

End Function
TIA
Amber

Nov 22 '05 #1
0 743

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

Similar topics

0
by: amber | last post by:
Can someone tell me what I may be doing wrong here... I'm trying to remove rows from a table in a dataset that have the same data. My code is pasted below. The 2nd time it runs through the code,...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
by: Geoff Jones | last post by:
Hi guys I'd be grateful if you could help me with the following question: I have a DataSet in which I'm using a SQL search string to find rows which satisfy a criteria. I'd then like to...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.