Trouble exporting a Table when using my own methods.

Posted on 2008-11-01
Medium Priority
Last Modified: 2013-11-26
If I was able to do
Dim dt As New MyTable
Or even simpler
Dim dt As New MyTable
When ever ExportToCSV is called, how does it know what table to export without me passing that table in?
Question by:rgn2121
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 12

Author Comment

ID: 22856097
ExportToCSV will be called on an object of MyTable which itself is a datatable.
Inside your Export method get the base class of the object which is a datatable and perform the operation on this object
LVL 12

Author Comment

ID: 22856098
That is what I am not sure about...Normally I pass in a destination file path of where it is to be exported and the table to export.

Sub ExportToCSV()

...Some Code

End Sub
LVL 12

Author Comment

ID: 22856108
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22856129
Hi rgn2121,

When calling a method of an object (in this case, a MyTable object, which inherits from DataTable), you can access the underlying DataTable using the "Me" keyword.


LVL 12

Author Comment

ID: 22856137
What if I use your nested class example?  Me would then refer to the ExportClass correct?
LVL 47

Accepted Solution

Wayne Taylor (webtubbs) earned 2000 total points
ID: 22856151
>>Me would then refer to the ExportClass correct?

Yes, if used in the ExportClass class. To "attach" a table to the ExportClass, pass it with the New procedure, as below.

The question I have though, is do you really need the ExportClass? Probably not. I'd simply have an ExportToCSV() routine in the MyTable class.

Public Class MyTable
    Inherits System.Data.DataTable 
    Sub New()
    End Sub 
    Public Property Export() As ExportClass
        End Get
        Set(ByVal value As ExportClass)
            value.Table = Me
        End Set
    End Property 
    Public Class ExportClass
        Public Table As MyTable
        Public Sub New(ByVal mt As MyTable)
            Me.Table = mt
        End Sub
        Public Function ToCSV() As Boolean
            'export the table "Table"
        End Function
    End Class 
End Class

Open in new window

LVL 12

Author Comment

ID: 22856160
>>The question I have though, is do you really need the ExportClass? Probably not. I'd simply have an >>ExportToCSV() routine in the MyTable class.

No...I was just curious...I really do appreciate all the help...Thanks.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question