473,386 Members | 1,734 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,386 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

Sep 27 '05 #1
0 3666

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

Similar topics

3
by: Tome73 | last post by:
How can I easily add the rows of DataTable1 to the rows of DataTable2. Both queries are from the same table. I can always use the column names with myRow, but I was wishing for a shortcut. When I...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
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...
4
by: RG | last post by:
Using VB.NET, How do I insert rows from a SQL Server table into an Access table with the same structure (and also the reverse, from Access to SQL)? I’m new to this, so here’s what I’ve...
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,...
4
by: Andre | last post by:
I am ruinning this in the global.asa VIA Visual Studio VB .NET (framework 1.1) I have a access database with a table called tblCounters with a feild called Counters with on row of data in it...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.