samedi 7 mars 2015

C# Using strongly typed dataset tableadapter in data entry forms

I am writing a database using a strongly typed dataset as windows forms project in C#. The database has one main form and a series of data entry forms (dialogs). I would like to update my disconnected SQL server database once the data entry form has been filled in using the tableadapter.update method directly from the data entry dialogs. I am unsure of the most robust solution to this problem. Some options I have considered are as follows.




  1. Use a dialog.Ok returned from data entry form to signal the main form to call table tableadapter.update.




  2. Pass the relevant table adapter in the dialog form constructor and call the update method from the dialog form.




  3. Set a property on the dialog form that sets the table adapter to be used for updating form the dialog form.




  4. Write a public method on the main form that calls tableadpter.update and call this method from the data entry dialogs.




With so many options I am curious to know what others have done, and what unseen pitfalls may exist in each of the possibilities that I have considered.


Having searched extensively for a solution, I am unable to find any widly accepted solutions to using tableadapter.update in another form.


I understand that I could drag and drop a tableadapter to my dialog froms but would prefer not to do this as they are already created in the main form.


Aucun commentaire:

Enregistrer un commentaire