1.11M Members

add, save records using binding navigator

 
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

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

 
0
 

THANKS. LOTS OF BENIFIT I HAVE GOT THANKS A LOT

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article