1

Hi to all

I used standard item in binding navigator such as add and save button. How can I modified the code for add records button like if the user press this button then insert to my database and for the save button to save in my database. I already tried to add and save but it was not add and save to my database.

Thanks

4
Contributors
3
Replies
14
Views
9 Years
Discussion Span
Last Post by Pradip sarma
0

just try below code in your add button to add record using binding navigator
note : suppose you have datasource nam ds,tablename is cTablename

myCurrencyManager = (CurrencyManager)FormName.BindingContext[ds, cTableName];
            myCurrencyManager.Position = 0;
            bs = new BindingSource();
            bs.DataSource = ds.Tables[cTableName];
            bindingNavigator1.BindingSource = bs;
            if (bs.Count == 0)
            {
                lInsert = true;
                myCurrencyManager.AddNew();
                myCurrencyManager.EndCurrentEdit();
            }
1

For save button add this code to click event:

Me.Validate()
Me.BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DataSet)
Me.Close()

For add button add this code to click event:

BindingSource.AddNew()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.