none
Working with Bound Controls Without Binding Navigator RRS feed

  • Question

  • Dear Experts

    I am trying to have bound controls with my own navigation buttons. Through Configuration wizard i created the DataSet and Dropped all the fields Using Details View on to Visual Basic form.  And wrote small code for navigating in two buttons

    FriendsBindingSource.MoveNext()
    and FriendsBindingSource.MovePrevious

    WORKS fine. Now i want to delete so i created a button and in the event i have put the following code

    FriendsBindingSource.RemoveCurrent()
    FriendsBindingSource.EndEdit()     ' This works for the session - it deletes it but When i reload the form The record is.
    ' still there. It is not deleted from the DataBase.

    Could you please throw some light as to how this thing will work?  I  would appreciate your help on this

    Best Regards
    Manish



    Friday, August 1, 2008 1:09 PM

Answers

  • Hi Manish

     

    Let's try this

     

    FriendsBindingSource.RemoveCurrent()

    TableAdapter.Update(FriendsBindingSource.DataSource)  'TableAdapter created for the DataSet

     

    This should do the trick.

     

    DataSet is a disconnected cache of data in memory in order to update or reflect your changes in the DataBase you have to create a TableAdapter that apply the changes.

    Typically if you drag a Table to a DataSet designer a TableAdapter is auto generated that you can use it. This behavior is available since VS2005.

     

     

    Best Regards

    Juan

     

    Wednesday, August 6, 2008 9:28 PM
    Moderator
  • Hello Manish,

     

    So for step 7 you just need to call before Update:

     

    FriendsBindingSource().EndEdit()

     

    This should do the trick. I hope this helps with the tutorial that's a great thing you're doing! Please let me know if this helps.

     

    Best Regards

     

    Juan

    Monday, August 18, 2008 10:09 PM
    Moderator

All replies

  • Hi Manish

     

    Let's try this

     

    FriendsBindingSource.RemoveCurrent()

    TableAdapter.Update(FriendsBindingSource.DataSource)  'TableAdapter created for the DataSet

     

    This should do the trick.

     

    DataSet is a disconnected cache of data in memory in order to update or reflect your changes in the DataBase you have to create a TableAdapter that apply the changes.

    Typically if you drag a Table to a DataSet designer a TableAdapter is auto generated that you can use it. This behavior is available since VS2005.

     

     

    Best Regards

    Juan

     

    Wednesday, August 6, 2008 9:28 PM
    Moderator
  • Hi Juan

     

    Thanks a lot

     

    Manish

    Thursday, August 7, 2008 12:15 PM
  • Hi Juan

     

    Can you please help me with Add a new record and save that one too.

    What i am doing is

     

    FriendsBindingSource.AddNew()

     

    In the Save Button i am doing the same thing you suggested

     

    FriendsTableAdapter.Update(FriendsBindingSource.DataSource) 'TableAdapter created for the DataSet

     

    But it does not save into the database.

     

    Thanks

     

    Manish

     

    Thursday, August 7, 2008 12:35 PM
  •  

    Hi Manish,

     

    I need a little more information on this. I understand two ways of doing this but I need more info on how do you want to do this and what are you getting.

     

    I created a "New" button which executes

    FriendsBindingSource.AddNew()

    and adds a row into the grid, then I enter the information on the grid and hit "Save" button which executes 

    FriendsTableAdapter.Update (FriendsBindingSource.DataSource)

    As a result you have the new row into your database.

     

    Other way I did this was to create a "Save" button which takes de information of the new row and then executes

    MyDataSet.MyTable.AddMyTableRow("NewRow")

    FriendsTableAdapter.Update (FriendsBindingSource.DataSource)

     

    Please let me know if this helps or how do you want to do this

     

    Best Regards

    Juan

    Thursday, August 7, 2008 7:28 PM
    Moderator
  • Hi Juan

    I am really indebted to your for helping me with this.

    1. i have a manually designed form with labels and text boxes.
    2. i have btnMoveNext,btnMovePrevious,btnAdd,btnAddSave,btnModify,btnModifySave,btnDelete,btnExit
    3. i have created a typed dataset

    4. From the DataSources panel i am dragging field by field into their respective text boxes. i am not changing it (the dataset) to detail view and drag the entire set this way the binding navigator also comes in. I dont want binding navigator because the idea is to have my own navigations. i am doing this tutorial for kids and it was a raging success when i had done in Visual Basic 4.0. Everyone understood the concept so well.

    5.i have coded the movenext and moveprevious. Delete works like a charm thanks to you

    6. In the btnAddNew i have the following code

            FriendsBindingSource.AddNew()
            btnAddSave.Visible = True
            ' Sure enough it creates a new record as it empties all the textboxes in the

    7, in the btnAddSave i have the following code

            FriendsTableAdapter.Update(FriendsBindingSource.DataSource) 
            btrAddSave.Visible = False

    8. Poof! Nothing in the database.Great expectations are shattered.

    Thanks a lot for venturing to help me out with this one. it is a part of tutorials for kids. First i show them binding navigator. then i will show them to have slightly more control. then i plant to teach them to work with unbound controls. This one is already completed. i hope this learning path will be valid in ADO.net sceneario. it was ok with DAO - and ADO

    With Best Regards

    Manish

    Friday, August 8, 2008 4:28 AM
  • Hello Manish,

     

    So for step 7 you just need to call before Update:

     

    FriendsBindingSource().EndEdit()

     

    This should do the trick. I hope this helps with the tutorial that's a great thing you're doing! Please let me know if this helps.

     

    Best Regards

     

    Juan

    Monday, August 18, 2008 10:09 PM
    Moderator
  • Hello Juan

    Thanks it works exactly as expected. Sorry i did not check this for a long time. I am really thankful to you

    Best Regards

    Manish
    Wednesday, September 10, 2008 10:26 AM