Skip to content

Convert the code in C# written in VB.NET

Rajeev Ranjan

Asked Jun 16, 2007, 11:16 AM EDT1 answer
Share
LinkedInX

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 = "New!"
            Else
                If thisTopId <> 0 Then
                      thisName = "" & thisName & ""
                Else
                      thisName = "" & thisName & ""
                End If
            End If


            Return thisName
        End Function

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    There are many pay sites that will convert code for you. Otherwise you need to do it on your own
    0