Solved

BIndingSource Update Issue

Posted on 2007-11-16
8
4,467 Views
Last Modified: 2013-12-17
I have a textbox linked to a dataset using bindingsource. What's happening is that when i want to save the changes to the database it is not taken the changes.
I use something like this.
bb.bindingsource.endedit();
dttableadapter.update(datasetname.table);
If I look at the dataset in the IDE viewer I can see the record that has been changed properly. For some reason it not flagging as changes though.
I have even tried:
Datatable data = datasetname.table.getchanges();
int rec = data.rows.count
and nothing shows. It is just a null value. I am not sure if I am missing something for the bindingsource or not.
Very odd.

This is c# and 2005.

Any ideas would be great!
0
Comment
Question by:bman9111
  • 5
  • 3
8 Comments
 
LVL 12

Expert Comment

by:topdog770
ID: 20313329
How are you connecting your bindingsource to the datatable?

Are you calling AcceptChanges somewhere along the way?
0
 
LVL 8

Author Comment

by:bman9111
ID: 20313678
I am connected through the datatable component. No I have not used any acceptchanges command.
0
 
LVL 12

Expert Comment

by:topdog770
ID: 20314461
If you call getchanges from the databinding itself, are the changes visible.  I'm thinking that there may be a disconnect between your binding and the dataset table your checking for changes.
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 8

Author Comment

by:bman9111
ID: 20314615
No its not showing changes. The weird part is that if you place your cursor over it via the IDE you can see the row changes.

0
 
LVL 12

Expert Comment

by:topdog770
ID: 20316146
Do you have a datagridview using the same binding source as the TextBox?  If so, make a change in the textbox THEN click in the datagridview and I am expecting that the dataset will have changes that get updated to the DB
0
 
LVL 12

Accepted Solution

by:
topdog770 earned 125 total points
ID: 20316193
Also, bman, where do you call EndEdit from and what is the bb object?  

I typically set up a function, like the Row_TextChanged function below that I call when the user changes the text in any bound controls.

Calling the EndEdit() function pushs the changes back to the dataset / datatable, etc behind the binding source
 void Row_TextChanged(object sender, EventArgs e)
        {
            this.bindingSource1.EndEdit( );
            Products.PACK_LABEL_PRODUCTSRow r = this.GetCurrentBindingSourceRow( );
 
            if (r != null)
            {
                if (r.RowState == DataRowState.Modified)
                {
                    SetSaveButtonEnabled( true );
                }
            }
        }

Open in new window

0
 
LVL 12

Expert Comment

by:topdog770
ID: 20316204
If you have an OK button or some similiar, you could also put the EndEdit there.
0
 
LVL 8

Author Comment

by:bman9111
ID: 20320048
ok. I redid all the binding and all seems ok. However even if a change is not done to any of the textboxs it still states there is a change to the dataset.
I am not sure why.

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question