I know this question has been asked dozens of times, but the code I have been looking at has not helped me.
So far I have been able to connect to the string and the database from where I need to check the username, but in my page it is not checking whether the username is correct or not.
Please someone tell me what I am doing wrong and what I need to change to make this work, I have been on this for literally a week and still no success.
Thank you!
protected void Verify_Click(object sender, EventArgs e)
{
//connect to sql
string ConnectString = "Data Source=sql12;Initial Catalog=import_log;Persist Security Info=True;User ID=sa;Password=password1";
SqlConnection con = new SqlConnection(ConnectString);
con.Open();
string sql = "SELECT userID from from user_verification WHERE userID = '" + username;
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (username.Text == "userID")
{
Output.Text = "Correct username";
}
con.Close();
}
}