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
}
First, you should be using parameters, rather than munging the query string with parameter values.
Second, you can convert to the type you want, which appears to be an integer:
SELECT CAST(isactive as int) as isactive
FROM user
WHERE email = '" + TxtEMail.Text + "'";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With