Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4476
  • Last Modified:

BIndingSource Update Issue

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
bman9111
Asked:
bman9111
  • 5
  • 3
1 Solution
 
topdog770Commented:
How are you connecting your bindingsource to the datatable?

Are you calling AcceptChanges somewhere along the way?
0
 
bman9111Author Commented:
I am connected through the datatable component. No I have not used any acceptchanges command.
0
 
topdog770Commented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
bman9111Author Commented:
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
 
topdog770Commented:
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
 
topdog770Commented:
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
 
topdog770Commented:
If you have an OK button or some similiar, you could also put the EndEdit there.
0
 
bman9111Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now