Multiple tables in dataset

  • Thread starter Thread starter Juan Romero
  • Start date Start date
J

Juan Romero

Hi guys,

Background:
I have a program that has a dataset with a table from SQL Server generated
with a data adapter.

The Question:
How do I add more than one table to the dataset? Do I have to add a new data
adapter for every table I add? or do I just configure the data adapter again
with a different table name to make it retrieve the table definition into
the dataset?

Thank you in advance.
 
Juan Romero said:
I have a program that has a dataset with a table from SQL Server generated
with a data adapter.
How do I add more than one table to the dataset? Do I have to add a new data
adapter for every table I add? or do I just configure the data adapter again
with a different table name to make it retrieve the table definition into
the dataset?

Juan,
You can have more than one SqlDataAdapter and fill the same DataSet.

Or you can have a single SqlDataAdapter which has more than one SELECT
statement in the SqlDataAdapter's SelectCommand.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at http://www.able-consulting.com
 
Thank you for your answer Carl.

The database contains about 35 tables. What would you recommend?

Also, I am having a problem with updating the underlying database. I add
a bunch of records, but when I call the method acceptchanges and check
the "haschanges" property of the dataset, it returns 0 (0 records have
updates pending).

Why doesn't it see the updates? I cannot get it to update the database.
Any help will be greatly appreciated.

Thank you in advance.
 
Juan Romero said:
The database contains about 35 tables. What would you recommend?

Juan,
What are you trying to do? Fill controls on a form? Transfer data? Other?
What environment are you using? WinForms? WebForms? XML Web Services?

Also, I am having a problem with updating the underlying database. I add
a bunch of records, but when I call the method acceptchanges and check
the "haschanges" property of the dataset, it returns 0 (0 records have
updates pending). Why doesn't it see the updates?

Why are you calling acceptchanges before the Update call? Calling acceptchanges
will reset each RowState to Unchanged. And hence the Update won't see any changes.

For more info, see
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataSetClassAcceptChangesTopic.asp

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at http://www.able-consulting.com
 
Back
Top