[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

passing a tableadapter to a function

Posted on 2007-12-03
2
Medium Priority
?
333 Views
Last Modified: 2010-04-21
I want to break my code into another function, as it is used by 3 functions...

            Dim IAdapter As New IDataSetTableAdapters.MemberTableAdapter
            Dim member As IDataSet.MemberDataTable
            member = IAdapter.GetDataByUserName(username)

' each function has a different "GetDataBy" above.... it might be by userName, UID, or email....
'But the below code stays the same in all of them....
' So How do I pass "member" to a function and then within the function retrieve it and use it as per below?

            Dim userID As Decimal = 0
            Dim password As String = ""

            If member.Rows.Count > 0 Then

                If Not member(0).userid = Nothing Then _
                    userID = member(0).userid
                If Not member(0).IspasswordNull Then _
                    password = member(0).password

thanks.
0
Comment
Question by:Starr Duskk
[X]
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
2 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 2000 total points
ID: 20402403
not quite sure if this is what you're looking for, but here goes:
public function MemberFunction (byval mbrdt as IDataSet.MemberDataTable) as string
 
            Dim userID As Decimal = 0
            Dim password As String = ""
try
            If mbrdt.Rows.Count > 0 Then
 
                If Not mbrdt(0).userid = Nothing Then _
                    userID = mbrdt(0).userid
                If Not mbrdt(0).IspasswordNull Then _
                    password = mbrdt(0).password
           ....
           return "" 'return nothing if no error
catch ex as exception
return ex.message.tostring 'if error return the error
end try
 
end function

Open in new window

0
 
LVL 2

Author Closing Comment

by:Starr Duskk
ID: 31412508
Perfect. thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 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