로그인 버튼을 클릭하면 if
대신 else
의 코드가 실행됩니다.처음 로그인 할 때 초보자입니다. 도움이 필요합니다.
실종 된 사람이 도와 줄 수 있습니까?
여기 내 코드입니다 :
SqlConnection cn = new SqlConnection(@"Data Source=COMPAQ-PC-PC\SQLEXPRESS;Initial Catalog=Gym;Integrated Security=True");
string SQL = "select username,password from login where username like '" + tbUserName.Text + "' and password like '" + tbPassword.Text + "'";
SqlCommand cmd = new SqlCommand(SQL, cn);
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
int roweffect = cmd.ExecuteNonQuery();
if (roweffect > 0)
{
Form2 login_Success = new Form2();
login_Success.ShowDialog();
}
else
{
MessageBox.Show("Please provide the correct username and password", "Invalaid Username OR Password", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
더 roweffect 변수 값을 가져옵니다 -1 ... 나는 ExecuteNonQuery는 통화에서 –
SELECT 문은 항상 반환 이유를 잘 모릅니다 -1 때문에 hasnt는 모든 행에 영향을 미칩니다. –
누가 행에 영향을 줍니까? –