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
Solved

passing a tableadapter to a function

Posted on 2007-12-03
2
328 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
daypilot scheduler 3 35
Deploying to Azure 3 39
VB.NET Textbox input validation 4 37
using CK editor in iframes 5 17
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…

856 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