Best practice for DataSet/DataTable use w/several forms

G

Guest

Hi,

None of the C#/ADO documentation I was able to read refers what are the best
practices/implementations for this "kind of" problem, I would like to get
help/opinions please, let me explain it:

a) The App have several forms, parent and childs.
b) On the parent Form I have one DataGrid displaying "myDataTable".
c) On child Forms I have to edit just one Row of data from "myDataTable".
d) After the Row edit finish on the child form the DataGrid on parent form
must update.

1) Should we keep "myDataTable" on one static variable on parent Form and
pass it to child forms as parameter to allow that child form to use
"myDataTable" ?

2) Or should we use one independent instance/connection for "myDataTable" in
each new child form we create ?

3) Any other best practice ?

Thanks.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Or course you will not find an answer like this in an ADO book, this is more
a design question.

The answer depend of your particular application.

I see two options:

1- You keep the Dataset private to Form1 , when you edit one row you pass
this row to the child form, it does update there and after that all you
would have to do is refresh the parent form. I would go this way if the
application is small or the data being edited is simple, if it does depend
of other tables or you have several tables that are related I would go for
option 2)

2- You create a static class from where you access the dataset, this way
it's available to all the application. You define methods to load/save or
make any other needed manipulation there.


cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top