Return a value from sql

Im trying move my sql connection to a method in a class file and return a value to check if the username existing in the db and display as text in the page to show others that the username exist. How should i modify my aspx .cs page to display error as a label in the aspx code page?