1
Answer

Convert the code in C# written in VB.NET

Rajeev Ranjan

Rajeev Ranjan

17y
1.7k
1

Public Function getLastPosterByTopic(ByVal topicId As Integer)
            Dim myConnection As New SqlConnection(ConfigurationManager.AppSettings("forumDSN"))
            Dim myCommand As New SqlCommand("SELECT TOP 1 psId, psRelTopId, psName FROM forumThreads WHERE psRelBcId = " & topicId & " ORDER BY psDate DESC", myConnection)

            myConnection.Open()

            Dim myReader As SqlDataReader
            myReader = myCommand.ExecuteReader()

            Dim thisId As Integer
            Dim thisTopId As Integer
            Dim thisName As String

            While myReader.Read()
                thisId = myReader("psId")
                thisTopId = myReader("psRelTopId")
                thisName = myReader("psName")
            End While
            myReader.Close()
            myConnection.Close()

            If thisName = "" Then
                thisName = "<font class=""labelNew"">New!</font>"
            Else
                If thisTopId <> 0 Then
                      thisName = "<a class=""lastPostLink"" href=""threadView.aspx?id=" & thisTopId & """>" & thisName & "</a>"
                Else
                      thisName = "<a class=""lastPostLink"" href=""topicView.aspx?id=" & topicId & """>" & thisName & "</a>"
                End If
            End If


            Return thisName
        End Function

Answers (1)