Why does this code block say "not all code paths return a value"?
<p>I wrote following code...but i am getting Error like:</p>

<p><strong>Error 1 'LoginDLL.Class1.Login(string, string, string)': not all code paths return a value</strong></p>

<p>Please help me...</p>

<p>Thanks in advance...</p>

<p>My code is as given below...</p>

<pre><code>public int Login(string connectionString,string username,string password)
{
    SqlConnection con=new SqlConnection(connectionString);
    con.Open();

    SqlCommand validUser = new SqlCommand("SELECT count(*) from USER where username=@username", con);
    validUser.Parameters.AddWithValue("@username", username);
    int value=Convert.ToInt32(validUser.ExecuteScalar().ToString());
    if (value == 1)
    {
        //check for password
        SqlCommand validPassword = new SqlCommand("SELECT password from USER where username=@username", con);
        validPassword.Parameters.AddWithValue("@username", username);
        string pass = validPassword.ExecuteScalar().ToString();
        if (pass == password)
        {
            //valid login
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else if (value == 0)
    {
        return 2;

    }
}
</code></pre>
