I am getting the follpwing error
Error:System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'where'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection
I have writtrn the code for connction as
SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
con.Open();
string checkuser = "select count(*) from Userdata where Username = '" + txtUserName.Text + "'";
SqlCommand com = new SqlCommand(checkuser, con);
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
if (temp == 1)
{
Response.Write("User Already Exists");
}
Loading

Jitendra KumarRank #760 · 3K reputationPosted Jan 21, 2015, 7:09 PM EST
Check select query. in sql server run the query and check error. if any problem plz let me know.
select count(*) from Userdata where Username = '"' + txtUserName.Text + '"'
Richel Debalucos8 reputationPosted Jun 10, 2022, 2:28 AM EDT
Abhishek ChadhaRank #402 · 6.2K reputationPosted Jun 10, 2022, 2:52 AM EDT
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 21, 2015, 7:59 PM EST
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);