I would say the code you shared is rather kid'ish.. Anyways, here is the issue and suggestion to make it better
Issue:
select Username from [Login]
Query will return all the usernames from database. So, you are iterating the whole result set. Assuming that the username will occur just once in you table, the if condition will return true just one, and for rest of the time it will fall in else and hence the issue. To fix this, exit the loop as soon as you enter the if condition. It will terminate the loop.
I could not see the purpose of this loop unless you make us understand.
Suggestion:
Filter the result set in your SQL query by writing
select Username from [Login] WHERE Username = '<username from textbox>'
This will allow you to check the database for username without iterating the entire result set. Think of a scenario where you have 10000 users and they all are accessing your page. It will make you loop run 10000*10000 times.