private Boolean exists()
{
SqlConnection conn = new SqlConnection("your Connectionstring");
SqlCommand cmd = new SqlCommand("Select Count(*) from DSusers where Username = @Username", conn);
SqlDataReader sReader = null;
Int32 numberOfRows = 0;
try
{
conn.Open();
sReader = cmd.ExecuteReader();
while (sReader.Read())
{
if (!(sReader.IsDBNull(0)))
{
numberOfRows = Convert.ToInt32(sReader[0]);
if (numberOfRows > 0)
{
return true;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
return false;
}
No comments:
Post a Comment