Sourav Kumar Das

Sourav Kumar Das

  • 526
  • 2.5k
  • 171.5k

Error while Conversion.

Sep 17 2018 2:17 AM
Getting Error in this Coloured Line....
 
"An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: Conversion failed when converting the varchar value '[email protected]' to data type int."
 
public bool IsUserExist(string Emailid)
{
bool flag = false;
SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
connection.Open();
SqlCommand command = new SqlCommand("select count(*) from Register where UserID = '" + Emailid + "'", connection);
flag = Convert.ToBoolean(command.ExecuteScalar());
connection.Close();
return flag;
}
 
If there's a solution please send me the answers....

Answers (1)