本文介绍了如何检索实际的列值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的工作中,我有一张桌子



In my work I have a table

reservation_available(seat_id, seat_type, flight_id, available)





其中flight_id是外键,seat_type连续有两个值(经济,商业)。要检索seat_id并且我写道:





where flight_id is a foreign key and seat_type has two value(Economic, Business) consecutively. To retrieve the seat_id and available I wrote:

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。但我想为所选的seat_type分别设置seat_id。



需要帮助



and similar code for the seat_type = "Business".

But retrieved data only shows the "seat_id" of seat_type = ''Business''. But I want respective seat_id for selected seat_type.

Help needed

推荐答案



这篇关于如何检索实际的列值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 17:17