472,127 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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 22614
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
reply views Thread by leo001 | last post: by

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.