private void txt_Fno_SelectedIndexChanged(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(ts.strcon))
{
SqlCommand cmd = new SqlCommand("Select Sno from ticket1 where Fno=@Fno and seattype=@seattype and flightdate=@flightdate", con);//查询customers表
{
SqlParameter ti_Fno = new SqlParameter("@Fno", txt_Fno.Text);
SqlParameter ti_seattype = new SqlParameter("@seattype", txt_seattype.Text);
SqlParameter ti_flightdate = new SqlParameter("@flightdate", txt_flightdate.Text);
cmd.Connection.Open();//打开数据库连接
cmd.Parameters.Add(ti_Fno);
cmd.Parameters.Add(ti_seattype);
cmd.Parameters.Add(ti_flightdate);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())//循环读取数据//将数据库中有的Sno的值,txt_Sno中删除
{
txt_Fno.Items.Remove(reader["Sno"]);
}
reader.Close(); //关闭数据库连接
}
}
}
现在在做一个飞机票预定系统,我想让SQL server 中录入的座位号,C# Combo Box中没有,这样旅客选座时不会选重了,但是上面那段代码没有用,求大神指点!!