dcsimg
Results 1 to 5 of 5

Thread: [RESOLVED] looking for a way to refresh datagrid from another form after inserting

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,874

    Resolved [RESOLVED] looking for a way to refresh datagrid from another form after inserting

    hey
    i cant find a way to refresh the grid to see the new data that i entered after unloading
    would like to get some help
    salsa

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,625

    Re: looking for a way to refresh datagrid from another form after updating or inserti

    You're doing it the wrong way around. Update the grid first (or, more correctly, the grid's data source) then save changes from that back to the database. If you're really determined to do it the wrong way then all you need to do to get up-to-date data is exactly what you did when you opened the form, i.e. query the database. Why exactly do you think you need to initiate this from another form to begin with? What's the relationship? Explain rather than assuming that we will magically know all we need to know about your specific situation.

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,874

    Re: looking for a way to refresh datagrid from another form after updating or inserti

    i have 2 forms
    1 holds the frmcustomers with the data grid
    then if i want to add a new customer or edit then i open another form called FrmNewCust
    if there is a better method i would love to learn it

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,625

    Re: looking for a way to refresh datagrid from another form after updating or inserti

    Check this out as an example of one way to perform an edit in a dialogue:

    http://www.vbforums.com/showthread.php?469518

    In that case, the DataTable that is bound to the grid is populated manually. In a real app, you would use a data adapter to populate the DataTable and the same data adapter to save the changes back to the database. If you follow the instructions there, ShowDialog will return the DialogResult value that corresponds to the button the user clicked. If that was OK, you would then know that changes had been made and so you needed to call Update on the data adapter to save those changes back to the database.

    Adding might be done similarly, in which case you'd use a newly created DataRow that you then added to the DataTable before saving. The new DataRow could be created first and passed in tot he dialogue, in which case you could actually use the same dialogue for adding and editing. Alternatively, you could use a different dialogue retrieve the data from properties and create the DataRow afterwards. Your choice.

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    4,874

    Re: looking for a way to refresh datagrid from another form after updating or inserti

    great !!
    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width