What is the best way to display data from a previous form

D

dbuchanan

Hello,

Windows forms & database

What are the considerations when choosing how to display reference
information from the calling form? What is recommended?

Table1 is the parent of Table2.

Form1 allows data entry into Table1.
Form2 allows data entry into Table2.

Form1 (the parent) opens Form2 (the child)

I need to display six fields from the parent table or form.

I see my options as...

1.) Populate the child form from a stored procedure that uses a SQL
Server View that contains a relationship between the two tables. Supply
the PK of the parent as the parameter for the stored procedure used to
populate the child.

2.) Open the child form as ShowDialog from Form1 and hide rather than
close Form1. Open Form2 by calling a simple stored procedure that
reference only the child table supply the PK of the parent as the
parameter to filter the child table. Get the six reference fields
through the use of public fields or public properties.

There are other options but I believe the two above are better. Which
is the best and what are the considerations in choosing.

I favor #1 but have not worked with views and have reservations about
how to proceed.

Thank you,
dbuchanan
 
B

Bart Mermuys

Hi,

dbuchanan said:
Hello,

Windows forms & database

What are the considerations when choosing how to display reference
information from the calling form? What is recommended?

Table1 is the parent of Table2.

Form1 allows data entry into Table1.
Form2 allows data entry into Table2.

Form1 (the parent) opens Form2 (the child)

I need to display six fields from the parent table or form.

I see my options as...

1.) Populate the child form from a stored procedure that uses a SQL
Server View that contains a relationship between the two tables. Supply
the PK of the parent as the parameter for the stored procedure used to
populate the child.

Keep in mind, if you do a join then then the view will end up in one
DataTable, you'll also have redundant information since each child row also
contains the parent row data.
2.) Open the child form as ShowDialog from Form1 and hide rather than
close Form1. Open Form2 by calling a simple stored procedure that
reference only the child table supply the PK of the parent as the
parameter to filter the child table. Get the six reference fields
through the use of public fields or public properties.

If you are planning on closing Form1, then you could copy the parent DataRow
while passing it to Form2 before showing it. Then you fill the child
DataTable by a simple stored procedure.

Or just could pass Form1's DataSet to Form2 if it contains a parent
DataTable with one DataRow and an empty child DataTable.

HTH,
Geetings
 

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