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
Abhishek ChadhaPosted Jun 10, 2022, 6:52 AM
Richel DebalucosPosted Jun 10, 2022, 6:28 AM
Manish Kumar ChoudharyPosted Jan 22, 2015, 12:59 AM
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
Jitendra KumarPosted Jan 22, 2015, 12:09 AM
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 + '"'