All pastes #231873 Raw Edit

Shin-Ra

public text v1 · immutable
·published 2006-11-01 02:33 UTC
rendered paste body
''' <summary>
        ''' List the forums that belong to that category.
        ''' </summary>
        ''' <param name="CategoryID">The categoryID.</param>
        ''' <remarks>
        ''' Lists all of the forums that belong to that category id.
        ''' </remarks>
        Public Function ListCategory(ByVal CategoryID As Integer) As DataTable
            Using cmd As SqlCommand = sdc.CreateCommand()
                cmd.Parameters.AddWithValue("@CategoryID", CategoryID)
                Dim table As DataTable
                Try
                    If CategoryID = Nothing Or CategoryID.ToString.Trim() = "" Then
                        cmd.CommandText = "SELECT CategoryID, Name, SortOrder FROM bx_Category ORDER BY SortOrder"
                        Using dr As SqlDataReader = cmd.ExecuteReader()
                            table = New DataTable()
                            table.Load(dr)
                        End Using
                    Else
                        cmd.CommandText = "SELECT CategoryID, Name, SortORder FROM bx_Category WHERE CategoryID=@CategoryID"
                        Using dr As SqlDataReader = cmd.ExecuteReader()
                            table = New DataTable()
                            table.Load(dr)
                        End Using
                    End If
                Catch ex As SqlException
                    Throw ex
                Finally
                    cmd.Connection.Close()
                End Try
                Return table
            End Using
        End Function