I'm working on a simple asp.net log in page. a simple code when user log in it verifies with the sql and direct to the page for either staff or admin. but i have this error (int.Parse(myReader.ToString()) > 0) ... Input string was not in a correct format my code..
string Connection = "Data Source=(ip);Initial Catalog=..;Persist Security Info=True;User ID=(id);Password=(pass)";
SqlConnection myConn = new SqlConnection(Connection);
SqlCommand SelectCommand = new SqlCommand("select * from tar_login where Username ='" + txtUsername.Text + "' and Password='" + txtPassword.Text + "' and Position='" + ddlPosition.Text + "';", myConn);
myConn.Open();
var myReader = SelectCommand.ExecuteScalar();
myConn.Close();
if (myReader != null)
{
if (int.Parse(myReader.ToString()) > 0)
{
if (ddlPosition.Text == "Admin")
{
Response.Redirect("manager.aspx");
}
}
}
if (myReader != null)
{
if (int.Parse(myReader.ToString()) > 0)
{
if (ddlPosition.Text == "Staff")
{
Response.Redirect("staff.aspx");
}
}
}
else
{
Label1.ForeColor = System.Drawing.Color.Red;
Label1.Text = "Incorrect. Please try again";
myConn.Close();
}
.help as im new to asp.net and c#