469,288 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

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 22044
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bryan Shaw | last post: by
6 posts views Thread by BD | last post: by
2 posts views Thread by jehugaleahsa | last post: by
1 post views Thread by Cdude | last post: by
5 posts views Thread by jehugaleahsa | last post: by
2 posts views Thread by Eric B. | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.