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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 23, 2013, 10:19 AM
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";
}
}
}
}
Chandradev PrasadPosted May 25, 2013, 2:29 AM
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/
KRayudu VPosted May 24, 2013, 12:04 AM