Solved

passing a tableadapter to a function

Posted on 2007-12-03
2
326 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:BobCSD
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 1

Author Closing Comment

by:BobCSD
ID: 31412508
Perfect. thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now