これはC#プログラムです。このコード行に問題があります。
400以上の数字=
を入力します500以下の数字=
を入力します400から500までの数字を入力しますex401から499=
実行します空のinput=erorr入力文字=erorr
整数のみを個別に受け入れるコードと、空の入力を受け入れないコードも実行することに注意してください。
何が間違っていると思いますか?
int parsedValue;
if (int.Parse(txtVacate.Text) <= 400 || int.Parse(txtVacate.Text) >= 500)
MessageBox.Show("Romms provided is not vacant or does not exist at all.");
else if (txtVacate.Text == " ")
MessageBox.Show("You provide empty");
else if (!int.TryParse(txtVacate.Text, out parsedValue))
MessageBox.Show("Please provide right info");
else
{
MySqlConnection connection = null;
string hostname = "localhost";
string database = "aparece_hoteldb";
string username = "root";
string password = "";
connection = new MySqlConnection("host=" + hostname +
";database=" + database +
";username=" + username +
";password=" + password + ";");
string table = "reservations";
string query = "DELETE FROM reservations WHERE RoomNumber = " + txtVacate.Text;
connection.Open();
MySqlDataAdapter da_res = null;
DataSet ds_res = null;
ds_res = new DataSet();
da_res = new MySqlDataAdapter(query, connection);
da_res.Fill(ds_res, table);
MessageBox.Show("Room" + " " + txtVacate.Text + " " + "is now Vacant please reload!");
dataGridView2.DataSource = ds_res.Tables[table];
this.Close();