473,503 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingSource Removing Current Row

Greetings

I have a a simple application with 1 form. On my form I use a
BindingSource to bind a database table to a "table (gridDataView)" (one
in the database, one on my form, 2 different types of tables).

I want to remove the current row I tried :

GrantsBindingSource.RemoveCurrent();

this removes it from the list on the form, but does not remove it from
the database, so I tried this :

GrantsBindingSource.RemoveCurrent();
GrantsBindingSource.EndEdit();

this also did not work, so finally I uesd the following :

DataRowView drv = (DataRowView)grantsBindingSource.Current;
AcroDataSet.GrantsRow row = (AcroDataSet.GrantsRow)drv.Row;
grantsTableAdapter.Delete(row.login, row.application, row.level);
grantsBindingSource.RemoveCurrent();

This "works" but seems like a lot to just remove the current record, is
there a "better" way? some way I can use the BindingSource natively and
remove the item from the "list" and the database at the same time?

thanks in advance
troy
May 28 '07 #1
3 22987
Troy,

No, there is not. The binding source connects to a disconnected data
set. When you remove the current row, assuming that you are using a DataSet
or DataTable, it sets the state of the row to delete. You have to pass that
DataSet/DataTable to a data adapter in order to have the database updated.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"msnews.microsoft.com" <tr*******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Greetings

I have a a simple application with 1 form. On my form I use a
BindingSource to bind a database table to a "table (gridDataView)" (one in
the database, one on my form, 2 different types of tables).

I want to remove the current row I tried :

GrantsBindingSource.RemoveCurrent();

this removes it from the list on the form, but does not remove it from the
database, so I tried this :

GrantsBindingSource.RemoveCurrent();
GrantsBindingSource.EndEdit();

this also did not work, so finally I uesd the following :

DataRowView drv = (DataRowView)grantsBindingSource.Current;
AcroDataSet.GrantsRow row = (AcroDataSet.GrantsRow)drv.Row;
grantsTableAdapter.Delete(row.login, row.application, row.level);
grantsBindingSource.RemoveCurrent();

This "works" but seems like a lot to just remove the current record, is
there a "better" way? some way I can use the BindingSource natively and
remove the item from the "list" and the database at the same time?

thanks in advance
troy
May 28 '07 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Troy,

No, there is not. The binding source connects to a disconnected data
set. When you remove the current row, assuming that you are using a
DataSet or DataTable, it sets the state of the row to delete. You have
to pass that DataSet/DataTable to a data adapter in order to have the
database updated.

So, am i doing this incorrectly? How do I pass the DataSet associated
with my BindingSource to a dataadapter?

Thanks
troy
May 28 '07 #3
Troy,

The way you are doing it is right. I was just explaining why that way
was right.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Troy Bull" <tr*******@gmail.comwrote in message
news:et**************@TK2MSFTNGP03.phx.gbl...
Nicholas Paldino [.NET/C# MVP] wrote:
>Troy,

No, there is not. The binding source connects to a disconnected data
set. When you remove the current row, assuming that you are using a
DataSet or DataTable, it sets the state of the row to delete. You have
to pass that DataSet/DataTable to a data adapter in order to have the
database updated.


So, am i doing this incorrectly? How do I pass the DataSet associated
with my BindingSource to a dataadapter?

Thanks
troy
May 28 '07 #4

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

Similar topics

2
6316
by: Bryan Shaw | last post by:
I have a Windows app I am developing in VS .NET 2005 that is required to periodically look at the data in a table in an MS SQL 2000 database. The data is being changed from an external stored...
0
4120
by: Geoff | last post by:
Hi folks Calling BindingSource.ResetCurrentItem() is changing the BindingSource.Position in a way I don't understand. If I'm understanding the docs correctly, ResetCurrentItem() should simply...
1
3084
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the...
5
7826
by: Rob Dob | last post by:
Hi, I have two c# Winforms. the first form has a datagridview who's datasource is a bindingsource. when you double click on a datagridview row it then opens my second form, which has some...
6
14953
by: BD | last post by:
Hi, I have a "Cancel" button on a form to cancel any changes in the current item with the code BindingSource1.CancelEdit but this don't restore the older's values that had been changed. The...
2
3432
by: jehugaleahsa | last post by:
Hello: I have a BindingSource that has its DataSource set to a BindingList<Customerwhere Customer is a business object that manipulates a DataRow. All changes to a Customer instance, update a...
1
180
by: Cdude | last post by:
I need to access the current row of the bindingsource. I need to assign that row to a DataRow is this possible.The reason i want to do this is that i have a switch statement that needs the...
5
4904
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This...
2
16802
by: Eric B. | last post by:
I could use a little clarification on using a BindingSource with my DataTable. As I understand it, the BindingSource sits between my data source (a DataTable) and DataGridView and any changes made...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7258
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
6970
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
5558
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,...
1
4987
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...
0
4663
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
3156
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
1489
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 ...
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.