troubleshooting Question

Order by last time not working

Avatar of Member_2_5230414
Member_2_5230414 asked on
Visual Basic.NETSQL
5 Comments1 Solution193 ViewsLast Modified:
Im trying to display the last post by a user in a forum.
    Shared Function lastpost(ByVal title As String) As Results
        Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\perkinj\My Documents\Visual Studio 2010\WebSites\runningprofiles\forums\forum.mdb;")
        Dim cmd As New OleDbCommand
        cmd.Connection = con
        cmd.Parameters.AddWithValue("@title", title)
            Dim Res As Results
            cmd.CommandText = "Select Count(*) From forum where Forum =@title and numrep <> 0  "
            Res.Result2 = cmd.ExecuteScalar()
            cmd.CommandText = "Select  title + '|' + LastPoster +'|' + Format(lasttime, 'dd/mm/yyyy hh:mm:ss') from forum where Forum =@title order by Format(lasttime, 'dd/mm/yyyy hh:mm:ss') ASC"
            Res.Result3 = cmd.ExecuteScalar()
            Return (Res)
        Catch ex As Exception
            Throw ex
        End Try
    End Function

Open in new window

where title is the name of the forum

in my db i have

1  Jp    03/12/2011 13:47:13
2  BOB   17/05/2011 17:32:57

But no matter what it displays Jp always

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros