We help IT Professionals succeed at work.
Get Started

Order by last time not working

Last Modified: 2012-05-11
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
Watch Question
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE