OleDbDataAdapter and 2 DataTables!

  • Thread starter Thread starter Mehdi Mousavi
  • Start date Start date
M

Mehdi Mousavi

Hi folks,

Consider an SQL Server table that has got a PK (auto-identity column), which
has been referenced by another table as a FK. Then imagine 2 DataTables that
has been created to refer to the above-mentioned SQL Server tables, either
partially or completely. I need to know how can I read/write these
DataTables from/to those DataSources using the OleDbDataAdapter.

Any idea would be highly appreciated,

Thanks in advance,
Mehdi
 
Well,
Consider the Northwind database that comes by SQL Server and consider 2
DataTables, say, dtCategories and dtProducts. Now consider the following
SELECT statement:

SELECT Categories.CategoryID, Categories.CategoryName,
Categories.Description, Categories.Picture, Products.ProductName,
Products.ProductID FROM Categories INNER JOIN Products ON
Categories.CategoryID = Products.CategoryID

that has been written for the SelectCommand of OleDbDataAdapter.

Would you please drop me a code that updates the data back and force between
the mentioned DataTable (that has got a given schema) and the
above-mentioned DataSource?

Thanks

allirajan said:
i hope this will clear your doubts :

1. after creating two datatables.
2. create a Relation and map these two datatable with fields. (the
relation can be created only if the actual relation which is set in the
physically - PK and FK).
3. create a xxxCommandBuilder and pass as a argument of xxxDataAdapter
(the dataadapter will do the insert, update, delete by using the
CommandBuilder).
4. xxxDataAdapter.update(dataset-object, 'optional want to give specific tables')

there are lot of properties is there to check the only update, newly
inserted, deleted records can be updated back to database.
 
Back
Top