dimanche 27 août 2017

I can't Convert SQL Select Query Result to Bit

After the user has registered; the user's membership is saved as "passive" by default. I do this in the following way: I have a line called "active" in my user table and the data type of this field is bit and default value of this field is 0. What I want to do is: If the user has not activated his account, I want him to get warning but I got System.IConvertible error. My login.aspx.cs is as follows:

DataRow drlogin = function.GetDataRow("SELECT isactive FROM user WHERE email = '" + TxtEMail.Text + "'");
if(Convert.ToInt32(drlogin) == 0)
{
    string message = "<script>alert('You can't login because your account is not active!');</script>";
}
else
{
    // Login operations
}

Aucun commentaire:

Enregistrer un commentaire