PC Review


Reply
Thread Tools Rate Thread

Deleting record from bindingsource

 
 
John
Guest
Posts: n/a
 
      28th Feb 2010
Hi

I have a winform app with form control bound to a binding source
TblClientsBindingSource. The binding source has a data table as its data
source as per below code;

dAdapter = New OleDbDataAdapter("SELECT * FROM tblClients WHERE ...", Conn)
dAdapter.Fill(dTable)
TblClientsBindingSource.DataSource = dTable

My question is; how do I delete the record currently pointed to by the
binding source from the backend database table tblClients?

Thanks

Regards




 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      28th Feb 2010
John wrote:
> Hi
>
> I have a winform app with form control bound to a binding source
> TblClientsBindingSource. The binding source has a data table as its data
> source as per below code;
>
> dAdapter = New OleDbDataAdapter("SELECT * FROM tblClients WHERE ...", Conn)
> dAdapter.Fill(dTable)
> TblClientsBindingSource.DataSource = dTable
>
> My question is; how do I delete the record currently pointed to by the
> binding source from the backend database table tblClients?
>
> Thanks
>
> Regards
>


It must be bound to some control. The control is bound on a
DataMemeberValue from the bound source, which would have the record's
key. You need to get the key to the record from the control that's bound
to the bounding source.

If the binding control is like a DataGridView, then you would select the
record in the DataGridView on SelectedIndexChanged event of the control
using SlectedValue that has the key to the record to delete.

You would have a Delete button with a buton click event that will take
the SelectedValue and go back to the database with some routine to
delete the row out of the table by key.

The button click event would have code in it to do your binding source
and bind the source to the control again. The record is deleted, you get
the data from the table again, the record is not there now, and you bind
the new data to the control.

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      28th Feb 2010
Don't use dTable but dTable.DefaultView

To that you can add a rowfilter
dTable.DefaultView.rowfilter = "CustomersName = John"

The Class type of the DefaultView is DataView

Success


"John" <(E-Mail Removed)> wrote in message
news:u7v$(E-Mail Removed)...
> Hi
>
> I have a winform app with form control bound to a binding source
> TblClientsBindingSource. The binding source has a data table as its data
> source as per below code;
>
> dAdapter = New OleDbDataAdapter("SELECT * FROM tblClients WHERE ...",
> Conn)
> dAdapter.Fill(dTable)
> TblClientsBindingSource.DataSource = dTable
>
> My question is; how do I delete the record currently pointed to by the
> binding source from the backend database table tblClients?
>
> Thanks
>
> Regards
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting record from bindingsource John Microsoft VB .NET 2 28th Feb 2010 07:55 AM
Saving specific record in BindingSource John Microsoft ADO .NET 0 14th Nov 2008 09:15 AM
TableAdapter, BindingSource and DataSet - the first record. Hubert Wisniewski Microsoft VB .NET 1 23rd Jan 2008 01:59 AM
Adding Record Using BindingSource and BindingNavigator =?Utf-8?B?ZGVuIDIwMDU=?= Microsoft Dot NET Framework Forms 0 15th Jun 2006 07:51 AM
BindingSource - Detail view - Is Current record dirty? A.M-SG Microsoft Dot NET Framework Forms 1 27th Jan 2006 06:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:24 PM.