Solved

BIndingSource Update Issue

Posted on 2007-11-16
8
4,468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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