How to pass strongly-typed datasets to a function and back

I want to get information from a database about a file.  I have an asp.net app that uses a strongly-typed DataSet created by Visual Studio 2005 (vb.net).  This creates a TableAdapter and DataTable.  I would like to pass the TableAdapter and DataTable to a function and then return the TableAdapter and DataTable.  Perhaps I need to pass the whole dataset.  In any case, I can't find how to pass these back and forth.  Can you help?

I pick the TableAdapter and DataTable as shown below.  This works fine, except I can't see how I would pass this back and forth to a function.  Right now it's in my main presentation web page, and I want it to be in a separate class, like a data access layer.
If strLocation = "k" Then   
            If URL.IndexOf("company.com") <> -1 
                DocAdapter = New DocumentsDEVTableAdapters.DocumentsDEV_TableAdapter
                CurrentDT = New DocumentsDEV.DocumentsDEV_DataTableDataTable
            Else    'For Production and localhost:
                DocAdapter = New DocumentsPRODTableAdapters.DocumentsPROD_TableAdapter
                CurrentDT = New DocumentsPROD.DocumentsPROD_DataTableDataTable
            End If
        ElseIf strLocation = "h" 
            If GlobalVars.ReferringURL.IndexOf("company2.com") <> -1
                DocAdapter = New companyExtensionsDEVTableAdapters.companyExtensionsDEV_TableAdapter
                CurrentDT = New companyExtensionsDEV.companyExtensionsDEV_DataTableDataTable
            Else    'For Prod and localhost:
                DocAdapter = New companyExtensionsProdTableAdapters.companyExtensionsPROD_TableAdapter
                CurrentDT = New companyExtensionsProd.companyExtensionsPROD_DataTableDataTable
            End If
        End If
        CurrentDT = DocAdapter.GetFileName(strDocumentNumber)

Open in new window

psmithphilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

YiogiCommented:
I don't see where the problem is. Just passing the variables byref should suffice. It shouldn't matter if you pass a strongly typed object or whatever else.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
psmithphilAuthor Commented:
What you say sounds like what I need to do.  I'm trying to picture how you would have me set this up.  Would it look like I have here? (you can see I also don't know how I would set the datatype when I dimension DocAdapter & CurrentDT.
Dim DocAdapter
Dim CurrentDT
Dim DataSetMaker As DataSetProcessor
DataSetMaker = New DataSetProcessor
DataSetMaker.TestTheDataSet(DocAdapter, CurrentDT)
 
Public Class DataSetProcessor
    Public Sub TestTheDataSet(ByRef DocAdapter, ByRef CurrentDT)
        If strLocation = "k" Then
            If URL.IndexOf("company.com") <> -1 Then
                DocAdapter = New DocumentsDEVTableAdapters.DocumentsDEV_TableAdapter
                CurrentDT = New DocumentsDEV.DocumentsDEV_DataTableDataTable
            Else
        etcetera, etcetera . . .
    End Sub
End Class

Open in new window

0
YiogiCommented:
Assuming you have a custom adapter of your own then you'd set the datatypes as:
Dim DocAdapter As DocumentsDEVTableAdapters.DocumentsDEV_TableAdapter
and
Dim CurrentDT As DocumentsDEVDataSet.DocumentsDEV_DataTableDataTable

One mistake you are making is the data table. You are supposed to select the datatable somehow from your adapter, thats the purpose of having an adapter anyway.
It should be something like:
CurrentDT = DocAdapter .GetDataWithSomeMethodYouDefinedInYourAdapter("CriteriaToReturnData")

Passing the strong datatypes into a function is just the same as passing any other variable. If you want to try reading the following article. It explains pretty well how to create and use custom data adapters.
http://www.theserverside.net/tt/articles/showarticle.tss?id=DataSetDesigner
0
psmithphilAuthor Commented:
Thank you, Yiogi!   This was an excellent answer.  What you provided will make life a lot easier.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.