Hi,
You have multiple options to avoid duplicate insertion of data into Database.
Option 1:
Make the Username field as Primary Key/ Unique Key, so the same username data will not be inserted, which in turn throws an exception. You handle the appropriate exception and intimate the user.
Note: Here the Exception handling block and checking Database and throwing SL exception is more cost effective.
Option 2:
Create a Stored procedure and check for username availability with the Distinct of data in table.
Public bool GetUserAvaliablity(Username)
If the data is already available then intimate user.
List<string> lstUserName = new List<string>();
lstUserName.Add("Rajesh");
lstUserName.Add("Anand");
lstUserName.Add("Venky");
lstUserName.Add("Prabhu");
lstUserName.Add("Balu");
var userName = from name in lstUserName
where name == "Balu"
select name;
if(userName.ToString().Length > 0)
{
Console.WriteLine("Name Exists");
}