One table two forms

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I want to use one contacts table in two separate forms in different
contexts. One form is the main entry form and the other is the lookup form.
Currently I have the contacts table as part of my single dataset. Can I use
the same table or do I need another instance of the table or do I use two
dataadapters or what?

Thanks

Regards
 
You can sit that DataTable in a module or as a shared property of a class in
C#. You can reference it from both forms from there. If you are only using
it in the second instance for lookups, you'll be fine. If you are going to
update from either, it still shouldn't be a problem unless you plan on
needing different update logic.

Cheers,

Bill
 
I am using vb.net. I presume the datatables are defined in the vb file that
is generated by the dataset. If this is the case I ideally would not like to
touch it as it may be changed by the dataset code generator.

In the second form I have access to the same dataset (dim ds as dscontacts).
Now I am not sure how to proceed from here. Should I fill the ds again using
another dataadapter? Should I create another instance of the table in ds for
second form? or what?

As the data is already filled in the ds by the first form, I would ideally
like to re-use it for performance reasons.

Thanks

Regards
 
You can create multiple views on a DataTable;

DataView oDataView = new DataView(oDataTable);

Then set the UI's (such as a grid) DataSource to the oDataView.

Tony
 
Back
Top