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
Orlando SalcidoPosted Jun 18, 2007, 6:56 PM