i have created 2 pages login and password.and i am checking for duplicate entry of username.
i have written query for it.But how can prevent it from inserting if the username is same.i have tried further but it is wrong.pls help
here is my code-
protected void signupbtn_Click(object sender, EventArgs e)
{
try
{
conn.Open();
string st;
st = "select count(username)from login where username='" + txtname.Text + "'";
cmd = new SqlCommand(st, conn);
if (st > 0)
{
Response.Write("duplicate record");
}
else
{
cmd = new SqlCommand("insert into login(name,midname,surname,username,password,contact,dob,email,address,occupation,ltype) values('" + txtfirst.Text + "','" + txtmid.Text + "','" + txtsur.Text + "','" + txtname.Text + "','" + txtpass.Text + "','" + txtcontact.Text + "','" + txtdob.Text + "','" + txtemail.Text + "','" + txtaddr.Text + "','" + txtocc.Text + "','" + typeButtonList1.SelectedValue + "')", conn);
cmd.ExecuteNonQuery();
Response.Write("Record inserted");
}
}