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

Problem with DataRowCollection.RemoveAt() and OleDbDataAdapter.Upd

Hi,

I have encountered the following problem.

Say I have the following,

DataGridView dgv;
DataTable dt;
OleDbDataAdapter oleDb_da; (bound to a OleDb data connection)

dt is the bounded data source of dgv, and I use oleDb_da.Fill(dt) to fill
the data table.

If I execute dt.Rows.RemoveAt(row_index), the row is removed, instead of
marked delete. When I run oleDb_da.Update(), my database is corrupted since
the deleted row is not updated in my database.

When I simply delete a row from my DataGridView dgv, the deleted row is
still in the collection, but marked deleted. When I run oleDb_da.Update(),
everything works correctly. I assume DataGridView delete (e.g. select a row
and click the button delete), must have execute DataRow.Delete().

Has anyone encountered above? Does anyone have an answer why
DataRowCollection.RemoveAt() fails in this scenario?

Thanks,

--
George
Jun 8 '06 #1
2 3365
Hi George,

Thanks for your post!

Based on my experience DataGridView internally calls DataRow.Delete method
to delete that row, so the database updating will reflect the delete
operation. DataRowCollection.RemoveAt method will remove this row from the
row collection, so the database updating will not touch that row in the
database at all.

So, to update the database row deletion programmatically, I recommended you
to use DataRow.Delete method.

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 9 '06 #2
Hi George,

Have you got my reply? Is your problem resolved? Please feel free to tell
me, thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 13 '06 #3

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

Similar topics

2
by: Scott Adams | last post by:
When calling the Find function of a DataRowCollection, one has two options: Overloads Public Function Find(ByVal key As Object) As DataRow or Overloads Public Function Find(ByVal keys() As...
1
by: alanrn | last post by:
I've implemented a number of strongly-typed collections that inherit from CollectionBase and recently noticed something that I don't fully understand. CollectionBase defines method RemoveAt(). ...
4
by: Frnak McKenney | last post by:
I'm using an in-core DataSet as an image of my application's 'database' (a multi-table Access97 mdb file). Updates are made to the DataTables within the DataSet via forms with bound TextBoxes,...
3
by: clyyy2002 | last post by:
At added two column and more column hereafter,I immediately click del button,the program is no problem. but if i first click the DataGrid columnHeader and then click the del button, i find when...
0
by: Kelvin | last post by:
Hi All, Due to can't insert new row between row and row while current DataTable looping. In order to solve the problem, I need to clone it as new DataTable, while the DataTable Looping, it also...
1
by: VitorJOL | last post by:
Hello I have a listbox with a datasource.I want to remove a row from listbox but not remove it from the database. How can i do this ? PROBLEM:"Cannot modify the Items collection when the...
0
by: han zhiyang | last post by:
I decide to make the problem clear from tip to toe. my test code is from Anders Heilsberg's lecture on Tech-Ed 2004 on C# Language enhancement. I slightly modified the code,not to the core part...
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
3
by: Carlos | last post by:
Hi all, I have 2 asp .net 2.0 projects currently being developed. One is in VB .Net and the other in C#. In the VB .Net project I can cross-reference a datatable object using the...
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
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:
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.