Implementing Tuples

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

al4629740Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulEE Topic AdvisorCommented:
Concatenate in a SQL Server T-SQL query uses a plus symbol, but also note that if any column isn't a string, that has to be cast to varchar first.


T-SQL specific
        sqlCmd = sqlCmd & " select [System Name],AgencyID, AgencyID + '-' +  [System Name]"
        sqlCmd = sqlCmd & " select [System Name],AgencyID, cast(AgencyID as varchar) + '-' +  [System Name]"

reasonably generic
        sqlCmd = sqlCmd & " select [System Name],AgencyID, concat(AgencyID, [System Name])" -- does the type conversion for you


The SQL standard concatenation symbol is || but quoting a column name [using brackets] isn't standard either.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
al4629740Author 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.