Re: Strongly typed DataSets: Relation between DataTable and TableAdapter
- From: "Etienne-Louis Nicolet" <nie.msft@xxxxxxxxxxx>
- Date: Fri, 10 Apr 2009 13:46:45 +0200
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
.
- References:
- Strongly typed DataSets: Relation between DataTable and TableAdapter
- From: Etienne-Louis Nicolet
- Re: Strongly typed DataSets: Relation between DataTable and TableAdapter
- From: Cowboy \(Gregory A. Beamer\)
- Strongly typed DataSets: Relation between DataTable and TableAdapter
- Prev by Date: Re: Get Access mdb version
- Next by Date: Re: Create linked tables in Access database
- Previous by thread: Re: Strongly typed DataSets: Relation between DataTable and TableAdapter
- Next by thread: Re: Test Message (please disregard)
- Index(es):
Relevant Pages
|