Multiple occurrences of a table in dataset

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

John

Hi

I have a table with all my contacts clients & suppliers. A 'company type'
field specifies if a record is client or supplier.

Can I have the table twice in my dataset once with company type clients and
other with company type suppliers? If not, do I need two separate datasets
for each occurrence of the same table?

Thanks

Regards
 
The cool thing about dataSets is that you can have multiple tables. You just
give it a friendly name when you create your table -- there are multiple
ways to create the dataset using the DataAdapter.
 
Hi

Thanks. Using datadapter, at what stage do I give a name different to the
original name?

Thanks

Regards
 
Well you don't have to use a dataAdapter.
When you create your DataSet you create your tables.

DS myDS = new DS();
DataTable customers = myDS.Tables["Customer"];
DataTable suppliers = myDS.Tables["Suppliers"];

then you use the friendly name to switch back and forth between the tables.
 
Hi

I dragged the table twice on the dataset. So I have tblcontacts &
tblcontacts1 in dataset. I rename tblcontacts to tblclientcontacts. Now the
sql will not recognize it as trying to do select * from tblclientcontacts
gives error 'The Microsoft Jet database engine cannot find the input table
or query 'tblClientContacts'. Make sure it exists and that its name is
spelled correctly.'.

Basically I am still not sure how to have the tblcontacts table with two
different names in the dataset with two different underlying select
statements.

Thanks

Regards



Dennis Davitt said:
Well you don't have to use a dataAdapter.
When you create your DataSet you create your tables.

DS myDS = new DS();
DataTable customers = myDS.Tables["Customer"];
DataTable suppliers = myDS.Tables["Suppliers"];

then you use the friendly name to switch back and forth between the tables.



John said:
Hi

Thanks. Using datadapter, at what stage do I give a name different to the
original name?

Thanks

Regards

You
just
 
Yes someone please post, he is asking my question all over again that i
never quite understood,
This message was made just to mark this as unread.

Thanks

John said:
Hi

I dragged the table twice on the dataset. So I have tblcontacts &
tblcontacts1 in dataset. I rename tblcontacts to tblclientcontacts. Now the
sql will not recognize it as trying to do select * from tblclientcontacts
gives error 'The Microsoft Jet database engine cannot find the input table
or query 'tblClientContacts'. Make sure it exists and that its name is
spelled correctly.'.

Basically I am still not sure how to have the tblcontacts table with two
different names in the dataset with two different underlying select
statements.

Thanks

Regards



Dennis Davitt said:
Well you don't have to use a dataAdapter.
When you create your DataSet you create your tables.

DS myDS = new DS();
DataTable customers = myDS.Tables["Customer"];
DataTable suppliers = myDS.Tables["Suppliers"];

then you use the friendly name to switch back and forth between the tables.



John said:
Hi

Thanks. Using datadapter, at what stage do I give a name different to the
original name?

Thanks

Regards

The cool thing about dataSets is that you can have multiple tables. You
just
give it a friendly name when you create your table -- there are multiple
ways to create the dataset using the DataAdapter.



Hi

I have a table with all my contacts clients & suppliers. A 'company
type'
field specifies if a record is client or supplier.

Can I have the table twice in my dataset once with company type clients
and
other with company type suppliers? If not, do I need two separate
datasets
for each occurrence of the same table?

Thanks

Regards
 
Back
Top