Click here to Skip to main content
16,016,736 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn.Open();
string checkUser = " select count(*) form Userdata where Username='" + TextBoxUN.Text + "' ";
SqlCommand cmd = new SqlCommand(checkUser,conn);


*** getting exception ---
System.Data.SqlClient.SqlException was unhandled by user code
  HResult=-2146232060
  Message=Incorrect syntax near 'Userdata' 

at this line
C#
int temp= Convert.ToInt32(cmd.ExecuteScalar().ToString()); // ***

if (temp==1)
{
   Response.Write("User Already Exists");
}
conn.Close();
Posted
Updated 22-Apr-14 23:55pm
v3

1 solution

"FROM", not "FORM":
C#
string checkUser = " select count(*) form Userdata where Username='" + TextBoxUN.Text + "' ";
Should be:
C#
string checkUser = " select count(*) FROM Userdata where Username='" + TextBoxUN.Text + "' ";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900