Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / April 2006

Tip: Looking for answers? Try searching our database.

How to pass TableAdapater as parameter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ad - 22 Apr 2006 09:25 GMT
I want to create a function which take a TablAdapter as parameter and return
a typed DataTable. Like:

DataTable GetDataTable(TableAdapter adp)
{
      .....
}

But I find there is no parent class for specific TableAdapter.

How can I finish this function?
Miha Markic [MVP C#] - 22 Apr 2006 19:51 GMT
It is a Component derived class. The only way I see it is to pass a
Component and use reflection.

Signature

Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

>I want to create a function which take a TablAdapter as parameter and
>return a typed DataTable. Like:
[quoted text clipped - 7 lines]
>
> How can I finish this function?
JohnMSyrasoft - 22 Apr 2006 19:59 GMT
Can you be more specific on what you're trying to do?

TableAdapters are defined against a strongly-typed dataTable and the queries
contained in a TableAdapter must match the schema of the typed DataTable.  I
don't think there is a way to generically pass a TableAdapter as a parameter.

Like DataAdapter, TableAdapter has both Fill and GetData methods builtin.  
For TableAdapters, GetData returns a new strongly-typed datatable.

MyTypedDataSetTableAdapters.Table1TableAdapter adp;
MyTypedDataSet.Table1DataTable tbl = adp.GetData();

There isn't a 'parent' or generic tableAdapter class that specific
TableAdapters inherit from.  Since a TableAdapter is like having a collection
of predefined parameterized queries that match a specifc table schema, I'm
trying to determine why you would want to pass it as a parameter to a
function that can only return a strongly-typed table.

> I want to create a function which take a TablAdapter as parameter and return
> a typed DataTable. Like:
[quoted text clipped - 7 lines]
>
> How can I finish this function?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.