在我的工作中,我有一张桌子
reservation_available(seat_id, seat_type, flight_id, available)
其中 flight_id 是一个外键,而 seat_type 连续有两个值(Economic, Business)。要检索 seat_id 和可用,我写道:
using (SqlCommand command = new SqlCommand("SELECT seat_id, seat_type, available FROM reservation_available WHERE seat_type = 'Economic' AND reservation_available.flight_id = '" + flight_id + "' ", connection))
{
string s_ID = seat_id.ToString();
string e_avail = EconomicAvailable.ToString();
string st = seat_type;
SqlDataReader myReader = command.ExecuteReader();
while (myReader.Read())
{
s_ID = myReader[0].ToString();
st = myReader[1].ToString();
e_avail = myReader[2].ToString();
}
int sId = Convert.ToInt32(s_ID);
int eAvail = Convert.ToInt32(e_avail);
myReader.Close();
set2(sId, eAvail, st);
}
和 seat_type = 'Business' 的类似代码。
但是检索到的数据只显示了seat_type =“Business”的“seat_id”。但我想要所选座位类型的相应座位 ID。
需要帮助