There are so many places there that could be wrong, but lets start with teh obvious stuff..
string checkuser = " select count(*) from UserDetail where UserName='" + TextBoxUN + "'";
Won't do what you want; the string will be:
select count(*) from UserDetail where UserName='System.Web.UI.WebControls.TextBox'
Which won't match anything...unless you have a really dull user. You need TextBoxUN.Text instead, but...Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
Why?
Why are you getting an interger retirn value, converting it to a string, in order to convert it back to an integer, and put it into an integer variable? Doesn't that seem a little...um...pointless to you?
int temp = com.ExecuteScalar();
Does the job without the rubbish...
string insertQuery = "insert into UserDetail (UserName,E-Mail,Password,Age,Gender,Address,Qualification,Country) values (@Uname ,@email ,@password ,@age ,@gender ,@address ,@qualification ,@country)";
This causes teh problem you complain about: and it's pretty obvious why. Why did you put a hyphen in
E-Mail
? Didn't it occurr to you that SQL would see that as "
E
minus
Mail
" and complain? The best solution is remove teh hyphen form teh column name, but you could use delimiters round it:
string insertQuery = "insert into UserDetail (UserName,[E-Mail],Password,Age,Gender,Address,Qualification,Country) values (@Uname ,@email ,@password ,@age ,@gender ,@address ,@qualification ,@country)";
And one more thing: Never store passwords in clear text - it is a major security risk. There is some information on how to do it here:
Password Storage: How to do it.[
^]