Solved

BIndingSource Update Issue

Posted on 2007-11-16
8
4,464 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A short film showing how OnPage and Connectwise integration works.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now