나는 ASP.NET에서 내 웹 사이트에 대한 로그인 enterance에 대한 if 문을 만들려고합니다.asp.net : 왜 if 문이 작동하지 않습니까?
시간이 지나면 무언가가 null 인 경우 명령문을 입력하지 않는다는 사실을 무시합니다.
어디서 잘못 됐는지 말해 줄 수 있습니까?
connection.Open(); // 이름 * * *** 문자열 firstName = FirstNameTextBox.Text; string sqlquery = ("사용자 이름, 성, 사용자 이름, 암호) VALUES (@ 이름, @ 성, @ 사용자 이름, @ 암호)");
SqlCommand command = new SqlCommand(sqlquery , connection);
command.Parameters.AddWithValue("FirstName", firstName);
//LastName************
string lastName = LastNameTextBox.Text;
command.Parameters.AddWithValue("LastName", lastName);
//Username*************
string username = UsernameTextBox.Text;
command.Parameters.AddWithValue("UserName", username);
//Password*************
string password = PasswordTextBox.Text;
command.Parameters.AddWithValue("Password", password);
if (lastName != null || username != null || firstName != null || password != null)
{
if (PasswordTextBox.Text == ReTypePassword.Text)
{
Session["UserEnter"] = FirstNameTextBox.Text;
command.ExecuteNonQuery();
Response.Redirect("HomeAfter.aspx");
}
else if (PasswordTextBox.Text != ReTypePassword.Text)
{
ErrorLabel.Text = "Sorry, You didnt typed your password correctly. Please type again.";
}
else
{
ErrorLabel.Text = "Some Error has accured.";
}
}
else
{
ErrorLabel.Text = "Please fill all of the fields.";
}
connection.Close();
}
당신은 [String.IsNullOrWhiteSpace] (http://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace.aspx) 대신 사용할 수 있습니다. –