We help IT Professionals succeed at work.

Implementing Tuples

al4629740
al4629740 asked
on
83 Views
Last Modified: 2018-09-17
I am very new to VB.net.  

In the following code I am trying to implement tuples.  You'll notice in the SQL clause that I pulled [System Name] and Agency ID and I want them to appear as AgencyID &  "-" & [System Name]  in a dropdown list.  I'm figuring that I will use tuples in lstProfiles in order to create the list.  What changes do I need to make in order to make that happen?

 Public Function fetchActiveProfiles() As List(Of String)
        Dim lstProfiles As New List(Of String)

        Dim sqlCmd As String
        sqlCmd = ""
        sqlCmd = sqlCmd & " select [System Name],AgencyID"
        sqlCmd = sqlCmd & " from tblOrgProfile"
        sqlCmd = sqlCmd & " Where Active = 1"
        sqlCmd = sqlCmd & " order by [System Name]"

        Try
            Using con As New SqlConnection(GetConnectionString)
                con.Open()

                Using cmd As New SqlCommand(sqlCmd, con)
                    cmd.CommandType = CommandType.Text

                    Using rs As SqlDataReader = cmd.ExecuteReader()
                        If Not rs.HasRows Then
                            Return lstProfiles
                        End If

                        'rs.NextResult()
                        While rs.Read
                            lstProfiles.Add(rs.GetString(0))
                        End While
                    End Using
                End Using

                con.Close()
            End Using
        Catch ex As Exception
            Throw New DatabaseConnectionException()
        End Try

        Return lstProfiles
    End Function

Open in new window

Comment
Watch Question

EE Topic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Very good solution and that works well.  The purpose of me asking how to do this using tuples was mainly for learning purposes so if its possible for an expert to provide how I might do that using .NET that would be most helpful.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions