Solved

passing a tableadapter to a function

Posted on 2007-12-03
2
327 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
2 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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