473,484 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Delete DataRow In DataTable

Dim drTemp As DataRow
For Each drTemp In dtInvCharges.Select("invno ='" &
Me.txtInvNo.Text.Trim & "' ")
dtInvCharges.Rows.Remove(drTemp)
Next
I got a "Delete button" to delete all rows in that Table. and the process
"SAVE", In the screen , i can see the datagrid got nothing,
however, as i check back my table in SQL, The data still here ?? Please
help
bmInvInfo.EndCurrentEdit()
If dsInvInfo.HasChanges() Then
daInvChg.Update(dsInvInfo, strdtChg)
daInvInfo.Update(dsInvInfo, strdtInfo)
dsInvInfo.AcceptChanges()
ENDIF

Nov 21 '05 #1
3 11576
Agnes,

I thought that I had answered this question already 9 months ago to you

http://groups.google.com/group/micro...dd12fa1f12e784

A 'remove' removes a datarow from a datatable, therefore with an update it
cannot remove it from the database because there is nothing more.

A delete marks a not newly added datarow as to delete. After an update of
that original datatable or an acceptchanges the datarow will be removed from
the datatable.

I don't know if this helps now, however I hope it.

:-)

Cor
Nov 21 '05 #2
You removed the rows. Not marked them as deleted. So as far as the datatable
is concerned, it has no rows in it - and no changes to send. Call the
Delete method on the rows you want to delete.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
Dim drTemp As DataRow
For Each drTemp In dtInvCharges.Select("invno ='" &
Me.txtInvNo.Text.Trim & "' ")
dtInvCharges.Rows.Remove(drTemp)
Next
I got a "Delete button" to delete all rows in that Table. and the process
"SAVE", In the screen , i can see the datagrid got nothing,
however, as i check back my table in SQL, The data still here ?? Please
help
bmInvInfo.EndCurrentEdit()
If dsInvInfo.HasChanges() Then
daInvChg.Update(dsInvInfo, strdtChg)
daInvInfo.Update(dsInvInfo, strdtInfo)
dsInvInfo.AcceptChanges()
ENDIF

Nov 21 '05 #3
doh,

Although that answer was AFAIK now wrong.

Now I know that a delete from a datagrid using the AltKey does a delete.

Nevertheless is a remove as in your code the remove I was refering to.

Cor
Nov 21 '05 #4

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

Similar topics

4
10415
by: baylor | last post by:
i have a DataSet (TDS). It has 4 rows in it. i want to erase those. For the life of me i can't figure out how Option 1: foreach foreach (DataRow row in dataSet.MY_TABLE.Rows) { row.Delete(); }...
0
1313
by: Mark Jones | last post by:
I'm trying to delete a row from a DataGrid using a ButtonColumn with CommandName="Delete" by deleting the row in the underlying DataTable datasource, but it doesn't seem to be working at the...
2
2553
by: Mark Jones | last post by:
I'm trying to delete data from a DataGrid using a ButtonColumn with a CommandName="Delete" but it's not working a the min. I'm using session data which fills a DataTable which then fills the...
4
14382
by: Vijay Pote | last post by:
Hi All, i have a datatable in which iam creating 2 datacolumns , one is SampleID and second is TestType. iam creating a datarow depending on a for loop, if the for loop goes 5 times it will...
4
59293
by: Prince | last post by:
Hi All, Can anyone tell me how to Insert,Update and Delete a record into already existing DataTable? Looking forward for the reply... Thanx in advance... Regards,
16
17487
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...
1
3217
by: Ryan Liu | last post by:
Hi, When my code run to DataRow.Delete() It throws: System.ArgumentOutOfRangeException: Non-negative number required. Parameter name: length at System.Array.Copy(Array sourceArray, Int32...
6
28292
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a...
5
3098
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...
0
6949
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
7103
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,...
1
6809
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
7194
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
5403
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
4527
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3044
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3038
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1355
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.