SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["my-sttConnectionString"].ConnectionString);
cn.Open();
string checkuser = "select count(*) from accounts where username '" + main_username_txt.Text + "'";
SqlCommand com = new SqlCommand(checkuser, cn);
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
if (temp == 1)
{
cn.Open();
Label1.Text = "okay";
}
else
{
Label1.Text = "error!!";
}
why show error page:
Incorrect syntax near 'usertest'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.Sq ...
Go to the complete details ...