I want to delete a row from a dataset, and I use:
Dim SelectedRow() as DataRow = DataSet1.Table1.Select("Selection Criteria")
DataSet1.Table1.Rows.Remove(SelectedRow(0))
The SelectedRow returns 1 row = SelectedRow(0). This successfully removes
the row from the dataset, but upon calling the update command
(DataAdapter1.Update(DataSet1, "Table1") the database is not updated. When I
refresh the dataset, the removed row is still there. The update command
works successfully with inserted rows and other changes made to the dataset.
I have also tried using the SelectedRow().Delete and AcceptChanges, and I
get the exact same results. What's going wrong? 4 7895
Hi Nathan,
Use delete or deleteAt, remove and removeAt, remove also the information
that it is deleted.
Cor I want to delete a row from a dataset, and I use:
Dim SelectedRow() as DataRow = DataSet1.Table1.Select("Selection
Criteria") DataSet1.Table1.Rows.Remove(SelectedRow(0))
The SelectedRow returns 1 row = SelectedRow(0). This successfully removes the row from the dataset, but upon calling the update command (DataAdapter1.Update(DataSet1, "Table1") the database is not updated. When
I refresh the dataset, the removed row is still there. The update command works successfully with inserted rows and other changes made to the
dataset. I have also tried using the SelectedRow().Delete and AcceptChanges, and I get the exact same results. What's going wrong?
Just to further clarify what Cor said. When you use the remove or removeAt
methods. There is nothing left for update to use to update/delete the
corresponding row in the database. Delete method however, marks the row for
deletion, and therfore when the Update Method of the adapter runs, it knows
a row has been marked for removal from the database.
Regards - OHM
Cor wrote: Hi Nathan,
Use delete or deleteAt, remove and removeAt, remove also the information that it is deleted.
Cor
I want to delete a row from a dataset, and I use:
Dim SelectedRow() as DataRow = DataSet1.Table1.Select("Selection Criteria") DataSet1.Table1.Rows.Remove(SelectedRow(0))
The SelectedRow returns 1 row = SelectedRow(0). This successfully removes the row from the dataset, but upon calling the update command (DataAdapter1.Update(DataSet1, "Table1") the database is not updated. When I refresh the dataset, the removed row is still there. The update command works successfully with inserted rows and other changes made to the dataset. I have also tried using the SelectedRow().Delete and AcceptChanges, and I get the exact same results. What's going wrong?
--
Best Regards - OHM
O_H_M{at}BTInternet{dot}com
Nathan,
In addition to the others comments.
Calling DataRow.Delete marks the row to be deleted.
Calling DataRow.Remove physically removes the row from the collection.
Calling DataSet, DataTable, DataRow AcceptChanges marks the respective rows
as processed (unmodified).
DataAdapter.Update only processes rows that are not marked as Unmodified.
Hence calling DataRow.Delete followed by AcceptChanges causes nothing to
occur on your database.
David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press
covers this plus a plethora of other items about ADO.NET. I highly recommend
it as a good tutorial for ADO.NET & a good desk reference once you know
ADO.NET.
Hope this helps
Jay
"Nathan" <nk*********************@softhome.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... I want to delete a row from a dataset, and I use:
Dim SelectedRow() as DataRow = DataSet1.Table1.Select("Selection
Criteria") DataSet1.Table1.Rows.Remove(SelectedRow(0))
The SelectedRow returns 1 row = SelectedRow(0). This successfully removes the row from the dataset, but upon calling the update command (DataAdapter1.Update(DataSet1, "Table1") the database is not updated. When
I refresh the dataset, the removed row is still there. The update command works successfully with inserted rows and other changes made to the
dataset. I have also tried using the SelectedRow().Delete and AcceptChanges, and I get the exact same results. What's going wrong?
Thanks Jay. The delete method works without the accept changes. Obviously I
misunderstood something in the little info I have on this at the moment.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Nathan, In addition to the others comments.
Calling DataRow.Delete marks the row to be deleted. Calling DataRow.Remove physically removes the row from the collection. Calling DataSet, DataTable, DataRow AcceptChanges marks the respective
rows as processed (unmodified).
DataAdapter.Update only processes rows that are not marked as Unmodified.
Hence calling DataRow.Delete followed by AcceptChanges causes nothing to occur on your database.
David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press covers this plus a plethora of other items about ADO.NET. I highly
recommend it as a good tutorial for ADO.NET & a good desk reference once you know ADO.NET.
Hope this helps Jay
"Nathan" <nk*********************@softhome.net> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... I want to delete a row from a dataset, and I use:
Dim SelectedRow() as DataRow = DataSet1.Table1.Select("Selection Criteria") DataSet1.Table1.Rows.Remove(SelectedRow(0))
The SelectedRow returns 1 row = SelectedRow(0). This successfully
removes the row from the dataset, but upon calling the update command (DataAdapter1.Update(DataSet1, "Table1") the database is not updated.
When I refresh the dataset, the removed row is still there. The update command works successfully with inserted rows and other changes made to the dataset. I have also tried using the SelectedRow().Delete and AcceptChanges, and
I get the exact same results. What's going wrong?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Spanky |
last post by:
Thanks for any help in advance!
I have this order form where you add rows as you need them. The
routine to add fields is working fine. I am trying to add the ability
to delete rows if you...
|
by: jurson |
last post by:
Hello,
I remove row from DataTable. It works ok, the row is removed from
collection. It should be marked as 'detached'. Am I right?
Then I try to retrieve 'detached' rows using the code shown...
|
by: Dave |
last post by:
Tried posting in the Winform Forum without much luck, so posting here...
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is...
|
by: Luis Esteban Valencia |
last post by:
Hello
I wrote a program with code behind in C# to add row into table
dynamically and the program worked very well in .Net Framework 1.1. When I
run this program in .Net Framework 2.0 beta...
|
by: Niyazi |
last post by:
Hi all,
I have a dataTable that contains nearly 38400 rows.
In the dataTable consist of 3 column.
column 1 Name: MUHNO
column 2 Name: HESNO
Column 3 Name: BALANCE
Let me give you some...
|
by: Muzzy |
last post by:
Hi,
I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
|
by: Susan Mackay |
last post by:
I have a data table that is connected to a database table with a data
adapter in the 'standard' manner.
However I want to be able to remove selected rows from the data table (i.e.
no longer...
|
by: Liquidtouch |
last post by:
I have been searching on this for awhile and cant find anything and playing around with it got me no where. I will start with what I am after and then explain what I have.
I have a table with 3...
|
by: tucson |
last post by:
I have a gridview that has a blank row with 2 input fields: file to upload, and a description of the file. They click Add and a new row is added, Remove and the row is removed.
The problem is:...
|
by: =?Utf-8?B?TU1TSkVE?= |
last post by:
How to let user delete multi rows from the BindingSource while the
SelectionMode Property set to RowHeaderSelect
I have in my program datagridview bound it to sql table
Throw Bindingsource
To...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| |