1,105,320 Community Members

add, save records using binding navigator

Member Avatar
tirso
Newbie Poster
22 posts since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Naik Dhiren
Newbie Poster
16 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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();
            }
Member Avatar
martonx
Junior Poster in Training
51 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
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()

Pradip sarma
Newbie Poster
1 post since Jun 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

THANKS. LOTS OF BENIFIT I HAVE GOT THANKS A LOT

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