• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

passing a tableadapter to a function

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
Starr Duskk
Asked:
Starr Duskk
1 Solution
 
samtran0331Commented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Perfect. thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now