locked
Read a database from one form and update from another? RRS feed

  • Question

  • Hi Everyone,

     

    I have set up a main tab control form that allows me to display data from several tables in the same database.  Im using datagridviews to display the table data in each tab. The form is getting crowded, so I was thinking about allowing the user to insert new records to the tables in a new form by clicking on an "Add New" button.  It seems more intuitive than just adding the row within the grid.

     

    This button pops up a second form with a subset of the fields within the table.  I would like to use this second form to simply add a new record to this table, and then after validation, this form would close and update the original datagridview reflecting the new record.

     

    I'm new to forms programming, and I cant seem to figure out how best to handle the database insert.  The dataset created in the main form is not visible in Form2, so what would be the best way to insert this new row from Form2?

     

    Any help would be greatly appreciated.

     

    Monday, April 9, 2007 12:20 PM

Answers

  • Hi as you said The dataset created in the main form is not visible in Form2

    I suggest pass form1's dataset as parameter to instance of form2,

    you can define form2's constructor as public form( Dataset ds)

     

    another way is not touch form1, but update the database, and refresh form1's data form database.

    which one better according your solution 

     

    Wednesday, April 11, 2007 6:48 AM