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

Recommended Answers

All 3 Replies

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();
            }

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()

THANKS. LOTS OF BENIFIT I HAVE GOT THANKS A LOT

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.