The C# Code:
string str = "Data Source=(LocalDB)\\MSSQLLocalDB;";
str += "AttachDbFilename=|DataDirectory|DinoData.mdf;";
str += "Integrated Security= True";
SqlConnection c;
c = new SqlConnection(str);
SqlCommand Cdd = new SqlCommand("SELECT COUNT(*) FROM [User] WHERE UserName LIKE @Username;", c);
Cdd.Parameters.AddWithValue("@Username", txtuser.Text);
c.Open();
int NameExist = (int)Cdd.ExecuteScalar();
c.Close();
if (NameExist > 0)
{
CVName.IsValid = true;
if ((bool)Session["Conect"])
{
SqlCommand getlev = new SqlCommand("SELECT level FROM [User] WHERE Username like @user", c);
getlev.Parameters.AddWithValue("@user", txtuser.Text);
c.Open();
int a = (int)getlev.ExecuteScalar();
c.Close();
if (a>5)
{
CVSemi.IsValid = false;
if (a >= 10)
{
CVmax.IsValid = false;
}
else
CVmax.IsValid = true;
}
else
{
CVSemi.IsValid = true;
}
}
}
else
{
CVName.IsValid = false;
txtuser.CssClass = "err";
}
if (Page.IsValid)
{
/*Something happen*/
}
The validator CVmax always true
even when I turned the if to:
if (a >= 1)
I update the code the CVmax is always valid why?? I tried to do every thing but without success please help