how Check UserName Availability from database
using asp.net and sqlserver with example please
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted May 23, 2013, 6:19 AM EDT
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Check_Data_dosenot_exist_database
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
string str;
protected void btn_check_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select count(*)from employee where ename='" + txtUserName.Text + "'";
com = new SqlCommand(str, con);
int count = Convert.ToInt32(com.ExecuteScalar());
if (count > 0)
{
lblMessage.Text = "username exist";
}
else
{
lblMessage.Text = "username doesnot exist";
}
}
}
}
KRayudu V157 reputationPosted May 23, 2013, 8:04 PM EDT
Chandradev PrasadRank #822 · 2.8K reputationPosted May 24, 2013, 10:29 PM EDT
You can do this task using this approach without any post on clientside
http://chandradev819.wordpress.com/2013/03/15/how-to-check-emailid-availability-on-clientside-using-wcf-and-ajax/