473,406 Members | 2,619 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,406 software developers and data experts.

Trying to delete from datatable

Hi - I have a datatable, held in a session variable - I want to delete
all items in a particular category, but my code doesn't seem to delete
them - although the delete method is run:

Function delCat(ByVal Cat as integer)

objDT = Session("Cart")
Dim i as Integer
Dim test as Integer

For i = objDT.Rows.Count-1 to 0 step -1
test = CType(objDT.Rows(i)("Category"), Integer)
If test = Cat then
objDT.Rows(i).Delete()
End If
Next
Session("Cart") = objDT

End Function

Can anyone please help show me where I'm going wrong?

Thanks, Mark

*** Sent via Developersdex http://www.developersdex.com ***
Dec 12 '05 #1
4 1066
That marks the record for deletion when updating to a database. If you want
to physically remove it from the table, you have to call the Remove or
RemoveAt method.

"Mark" <an*******@devdex.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi - I have a datatable, held in a session variable - I want to delete
all items in a particular category, but my code doesn't seem to delete
them - although the delete method is run:

Function delCat(ByVal Cat as integer)

objDT = Session("Cart")
Dim i as Integer
Dim test as Integer

For i = objDT.Rows.Count-1 to 0 step -1
test = CType(objDT.Rows(i)("Category"), Integer)
If test = Cat then
objDT.Rows(i).Delete()
End If
Next
Session("Cart") = objDT

End Function

Can anyone please help show me where I'm going wrong?

Thanks, Mark

*** Sent via Developersdex http://www.developersdex.com ***

Dec 12 '05 #2
Hi - thanks, but I can't see a:

objDT.Rows(i).Remove in intellisense (VS.Net 2003)

Can you advise?

Thanks, Mark

*** Sent via Developersdex http://www.developersdex.com ***
Dec 12 '05 #3
> Hi - thanks, but I can't see a:

objDT.Rows(i).Remove in intellisense (VS.Net 2003)

Can you advise?

Thanks, Mark


try:

objDT.Rows.RemoveAt(i)
Hans Kesting
Dec 12 '05 #4
objDT.Rows.RemoveAt(i)

"Mark" <an*******@devdex.com> wrote in message
news:eh*************@TK2MSFTNGP10.phx.gbl...
Hi - thanks, but I can't see a:

objDT.Rows(i).Remove in intellisense (VS.Net 2003)

Can you advise?

Thanks, Mark

*** Sent via Developersdex http://www.developersdex.com ***

Dec 12 '05 #5

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

Similar topics

2
by: scott | last post by:
Hi all First off, thank you for any one that can help. I have a problem trying to link a DataGrideTableStyle to a DataGrid. I have a dataset which reads from a file a xml schema and a xml...
16
by: Sam | last post by:
Hi, As I loop through a dataview's records, I delete datarow based on a condition. However I don't want to commit those deletions until the loop ends. With a datatable, i would just set...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.