Getting -1 value from database
<p>I am making a Login Page. For that i am going to do authenticate the username and password from database. As i execute the program query will run and it return a -1 value. As the username and password is correct. Please Help me out. My program code is as Follow:</p>

<pre><code>public partial class Home : System.Web.UI.Page
{
    SqlConnection objcon;
    String query;
    SqlCommand cmd;
    int num;
    //SqlDataAdapter DataAdapter;

    protected void Page_Load(object sender, EventArgs e)//db open in page load.
    {
        objcon = new SqlConnection("Data Source String");
        objcon.Open();
    }
    //query execution and authentication on button click 

    protected void Button1_Click(object sender, EventArgs e)
    {
        query = "select * from tbl_user where UserName='" + txtUname.Text + "' and Password='" + txtPwd.Text + "'";

        cmd = new SqlCommand(query,objcon);

        num = cmd.ExecuteNonQuery();

        //Label3.Text = num.ToString();
        if (num == -1)
            Label3.Text = "Correct";
        else
            Label3.Text = "Incorrect";
        objcon.Close();
    }
}
</code></pre>
