Re: Strongly typed DataSets: Relation between DataTable and TableAdapter

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Sorry, this must have been a typical beginner's way to pose a question ;-)

Assuming I create a generic base base class like

' TDataRow refers to a DataRow in a strongly typed DataTable
Public MustInherit Class MyBusinessObjectBaseClass(Of TDataRow As DataRow)
Protected _databaseRecord As TDataRow
....
End Class

The objects derived from MyBusinessObjectBaseClass relate to a record in a
given database table and I'd like to put the logic to select, insert or
update the database records in the base class. Since the base class 'knows'
of what type my _databaseRecord is, isn't there a way to derive the
appropriate TableAdapter (and eventually the DataTable)?

If implemented in the derived object I would do someting like:

Dim ta As New MyDataSetTableAdapters.MyDataTableTableAdapter
ta.Update(_databaseRecord)

How, if possible, would I have to implement such methods in the base class?

Many thanks,
Etienne



"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx> wrote in
message news:uAhjycRuJHA.5452@xxxxxxxxxxxxxxxxxxxxxxx
In general, unless you have change the default query, you use

MyDataTable = MyTableAdapter.GetData();

This produces an "every row in the table" DataSet. You can create a Get
method every time you create a new query. There is also a fill method, but
it works like this:

MyDataTable table = new MyDataTable():
MyTableAdapter.Fill(table);

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*********************************************
| Think outside the box |
*********************************************
"Etienne-Louis Nicolet" <nie.msft@xxxxxxxxxxx> wrote in message
news:esr$2MPuJHA.5452@xxxxxxxxxxxxxxxxxxxxxxx
When creating a strongly typed DataSet using the "Add New DataSource..."
configuration wizzard a data table as well as a table adapter is created
for each database table.

Is there a way to get the DataTable a TableAdapter 'belongs' to by code?
Something like 'MyDataTable = MyTableAdapter.GetTable()' or so...? In
case would there be the opposite way, means getting the appropriate
TableAdapter from a given DataTable?

Many thanks for your help,
Etienne






.



Relevant Pages

  • Re: OOD Question
    ... your work order task might have the work order ... instance of the derived classes will give the same information, ... > makes a database call. ... > If theres some change in base class I need to take care of these in all the> derived classes as well. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Scrubbing MySQL Values and CSVtoArray()
    ... Sanders Kaufman wrote: ... then a base class that does the business logic. ... the mysql-specific scrubbing function in the business logic base class - ... it defeats the purpose of putting ALL of the database work in database.php. ...
    (comp.lang.php)
  • Re: Using a Resource as a Class Property
    ... I'm aggragating the database object into a base class, ... other classes that "extend" that base class. ... But if you want to overwrite some methods to ...
    (comp.lang.php)
  • Re: OOP and Pear::DB
    ... Have a common base class for all your classes that represents rows in ... database tables. ... class User extends DBObject { ... > I'd greatly appreciate some feedback from experienced PHP OOP ...
    (comp.lang.php)
  • Re: Scalability VS Performance
    ... >> A common approach here is to have a separate data source for each ... > Above solves the problem of referencing the base class specific ... > database fields in the derived (WorkOrderTask) class and this is also one ...
    (microsoft.public.dotnet.framework.performance)