You get some data from the database, which is a list
And you can select the last item from that list...
If you do not know how to do this, then learn how to select the last item from a list...do the list tutorial. .
And you could compare that item (whjch is the last message) with the text from the textbox...