You can do that in following ways
Check if duplicate
Create a method to check the username is already exists in database
public bool IsUsernameExists(string strUsername)
Throw the exception
Put a constraint for the
column in table. If you try to save duplicate name then it will raise the error, based on the error you can throw the appropriate message to the user.
Now you decide.