C# IndexOf(btn.ID.ToString()+“,”>-1) { this.txtseatnumber.Text=this.txtseatnumber.Text.Replace(btn.ID.ToString()+,,,); } 其他的 { this.txtseatnumber.Text=this.txtseatnumber.Text.Replace(btn.ID.ToString(),“”); } //numsets++; //numsets.Text=numsets.ToString(); HttpContext.Current.Session[“numsets”]=Convert.ToInt32(HttpContext.Current.Session[“numsets”])+1; numsets.Text=Convert.ToInt32(HttpContext.Current.Session[“numsets”]).ToString(); } else if(btn.ImageUrl==“~/Image/available\u seat\u img.gif”) { this.seattable.Visible=true; btn.ImageUrl=“~/Image/selected\u seat\u img.gif”; if(this.txtseatnumber.Text.Trim().Length==0) { this.txtseatnumber.Text=btn.ID.ToString(); } else if(this.txtseatnumber.Text.Trim().EndsWith(“,”)) { this.txtseatnumber.Text=this.txtseatnumber.Text+btn.ID.ToString(); } 其他的 { this.txtseatnumber.Text=this.txtseatnumber.Text+”,“+btn.ID.ToString(); } //单位数--; //numsets.Text=numsets.ToString(); HttpContext.Current.Session[“numsets”]=Convert.ToInt32(HttpContext.Current.Session[“numsets”])-1; numsets.Text=Convert.ToInt32(HttpContext.Current.Session[“numsets”]).ToString(); } } 受保护的void s1\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s1); } 受保护的void s2\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s2); } 受保护的void s3\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s3); } 受保护的void s4\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s4); } 受保护的void s5_单击(对象发送器,ImageClickEventArgs e) { 这个.seatClick(这个.s5); } 受保护的无效单击(对象发送器,图像单击事件参数e) { 本.seatClick(本.s6); } 受保护的void s7\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s7); } 受保护的void s8_单击(对象发送者,图像ClickEventArgs e) { 这个.seatClick(这个.s8); } 受保护的void s9_单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s9); } 受保护的无效s10_单击(对象发送者,图像单击事件参数e) { 这个.seatClick(这个.s10); } 受保护的void s11\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s11); } 受保护的void s12\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s12); } 受保护的void s13\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s13); } 受保护的无效单击(对象发送者,ImageClickEventArgs e) { 这是seatClick(这是s14); } 受保护的void s15\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s15); } 受保护的void s16\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s16); } 受保护的void s17\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s17); } 受保护的void s18\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s18); } 受保护的void s19_单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s19); } 受保护的void s20\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s20); } 受保护的无效按钮1\u单击(对象发送者,事件参数e) { //Summary.seats=txtseatnumber.Text; HttpContext.Current.Session[“seats”]=txtseatnumber.Text; 重定向(“/Admin/TransSummary.aspx”); 基础荷载(e); } 受保护的无效按钮2\u单击(对象发送者,事件参数e) { Response.Redirect(“/Admin/TransSample.aspx”); 基础荷载(e); } }

C# IndexOf(btn.ID.ToString()+“,”>-1) { this.txtseatnumber.Text=this.txtseatnumber.Text.Replace(btn.ID.ToString()+,,,); } 其他的 { this.txtseatnumber.Text=this.txtseatnumber.Text.Replace(btn.ID.ToString(),“”); } //numsets++; //numsets.Text=numsets.ToString(); HttpContext.Current.Session[“numsets”]=Convert.ToInt32(HttpContext.Current.Session[“numsets”])+1; numsets.Text=Convert.ToInt32(HttpContext.Current.Session[“numsets”]).ToString(); } else if(btn.ImageUrl==“~/Image/available\u seat\u img.gif”) { this.seattable.Visible=true; btn.ImageUrl=“~/Image/selected\u seat\u img.gif”; if(this.txtseatnumber.Text.Trim().Length==0) { this.txtseatnumber.Text=btn.ID.ToString(); } else if(this.txtseatnumber.Text.Trim().EndsWith(“,”)) { this.txtseatnumber.Text=this.txtseatnumber.Text+btn.ID.ToString(); } 其他的 { this.txtseatnumber.Text=this.txtseatnumber.Text+”,“+btn.ID.ToString(); } //单位数--; //numsets.Text=numsets.ToString(); HttpContext.Current.Session[“numsets”]=Convert.ToInt32(HttpContext.Current.Session[“numsets”])-1; numsets.Text=Convert.ToInt32(HttpContext.Current.Session[“numsets”]).ToString(); } } 受保护的void s1\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s1); } 受保护的void s2\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s2); } 受保护的void s3\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s3); } 受保护的void s4\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s4); } 受保护的void s5_单击(对象发送器,ImageClickEventArgs e) { 这个.seatClick(这个.s5); } 受保护的无效单击(对象发送器,图像单击事件参数e) { 本.seatClick(本.s6); } 受保护的void s7\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s7); } 受保护的void s8_单击(对象发送者,图像ClickEventArgs e) { 这个.seatClick(这个.s8); } 受保护的void s9_单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s9); } 受保护的无效s10_单击(对象发送者,图像单击事件参数e) { 这个.seatClick(这个.s10); } 受保护的void s11\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s11); } 受保护的void s12\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s12); } 受保护的void s13\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s13); } 受保护的无效单击(对象发送者,ImageClickEventArgs e) { 这是seatClick(这是s14); } 受保护的void s15\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s15); } 受保护的void s16\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s16); } 受保护的void s17\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s17); } 受保护的void s18\u单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s18); } 受保护的void s19_单击(对象发送者,ImageClickEventArgs e) { 这个.seatClick(这个.s19); } 受保护的void s20\u单击(对象发送者,ImageClickEventArgs e) { this.seatClick(this.s20); } 受保护的无效按钮1\u单击(对象发送者,事件参数e) { //Summary.seats=txtseatnumber.Text; HttpContext.Current.Session[“seats”]=txtseatnumber.Text; 重定向(“/Admin/TransSummary.aspx”); 基础荷载(e); } 受保护的无效按钮2\u单击(对象发送者,事件参数e) { Response.Redirect(“/Admin/TransSample.aspx”); 基础荷载(e); } },c#,sql,C#,Sql,这一行 string add = "set identity_insert ticketing off;insert into ticketing(seat,customerID,tripID,reservationdate,fare) values('" + (string)HttpContext.Current.Session["seats"] + "',(select distinct customerID from customer where email = '

这一行

            string add = "set identity_insert ticketing off;insert into ticketing(seat,customerID,tripID,reservationdate,fare) values('" + (string)HttpContext.Current.Session["seats"] + "',(select distinct customerID from customer where email = '" + (string)HttpContext.Current.Session["cusEmail"] + "'),(Select distinct tripID from trip where terminal = '" + (string)HttpContext.Current.Session["origin"] + "' and destination = '" + (string)HttpContext.Current.Session["destination"] + "'),GETDATE()," + totalfare + ")";
将要插入的值中有子查询。
“SELECT DISTINCT”可以返回多行,因此请确保这些子查询只返回一行。

此外,要添加到other提供的内容,您可以使用“TOP 1”仅获取第一行来保护您的子查询。

在哪一行有此错误?我猜是关于lb_状态。因为它是子查询语句显示会话[“TripID”]的地方,所以TripID值是int。文本中没有子查询。请只张贴发生错误的代码部分,并告诉我们如何重现它。
public partial class Customer_Seats : System.Web.UI.Page
{
private string connectionString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
private static DataSet ds = new DataSet();

private CryptoLibrary nCl = new CryptoLibrary();

private static string password;
private static int AnnouncementId;

private static System.IO.Stream fs;
private static System.IO.BinaryReader br;
private static Byte[] bytes;
public static int numseats;
public static string origin;
public static string destination;
private void ListFields()
{
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        string cmdstr = "Select Seat FROM Ticketing";
        SqlCommand cmd = new SqlCommand(cmdstr, connection);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);


    }
}
protected void ShowIndividucalRecord(int Announcementid)
{
    SqlDataReader rdr = null;
    SqlConnection conn = null;
    SqlCommand selcmd = null;
    List<string> seats = new List<string>();


    {
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connString"].ConnectionString);
        selcmd = new SqlCommand("Select Seat FROM Ticketing WHERE TripID=" + Announcementid, conn);

        conn.Open();
        rdr = selcmd.ExecuteReader();
        while (rdr.Read())
        {
            if (rdr.GetString(0).Contains(','))
            {
                string[] token = rdr.GetString(0).Split(',');
                foreach (string seat in token)
                {
                    seats.Add(seat);
                }
            }
            else
                seats.Add(rdr.GetString(0));
        }
        foreach (string seat in seats)
        {
            if (seat == "s1")
                s1.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s2")
                s2.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s3")
                s3.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s4")
                s4.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s5")
                s5.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s6")
                s6.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s7")
                s7.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s8")
                s8.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s9")
                s9.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s10")
                s10.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s11")
                s11.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s12")
                s12.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s13")
                s13.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s14")
                s14.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s15")
                s15.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s16")
                s16.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s17")
                s17.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s18")
                s18.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s19")
                s19.ImageUrl = "~/Image/booked_seat_img.gif";
            else if (seat == "s20")
                s20.ImageUrl = "~/Image/booked_seat_img.gif";
        }
        conn.Close();
    }
}
protected void GetIndividualRecord(int Announcementid)
{
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        string cmdstr = "Select Seat from Ticketing Where TripID =" + Announcementid;
        SqlCommand cmd = new SqlCommand(cmdstr, connection);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);
    }
}
protected void Page_Load(object sender, EventArgs e)
{
    numSeats.Text = Convert.ToInt32(HttpContext.Current.Session["numseats"]).ToString();
    if (!IsPostBack)
    {

        ListFields();


        try
        {
            AnnouncementId = int.Parse(Context.Request.QueryString["TripID"].ToString());

            ShowIndividucalRecord(AnnouncementId);
        }
        catch
        {
            string source,
            message,
            back;
            source = "Admin Customer List";
            message = "You directly open the Admin Customer Update page without specifying a record.";
            back = "Please click the browser's back button to display the Admin Customer List.";


            Response.Redirect("/messages/generalerror.aspx?source=" + source + "&message=" + message + "&back=" + back);
        }
    }

}
protected void seatClick(ImageButton btn)
{

    //this.ibnext.Visible = true;
    if (btn.ImageUrl == "~/Image/available_seat_img.gif" && Convert.ToInt32(HttpContext.Current.Session["numseats"]) == 0)
    {
        this.seattable.Visible = true;
        btn.ImageUrl = "~/Image/available_seat_img.gif";


    }
    else if (btn.ImageUrl == "~/Image/selected_seat_img.gif")
    {
        this.seattable.Visible = true;
        btn.ImageUrl = "~/Image/available_seat_img.gif";
        if (this.txtseatnumber.Text.IndexOf(btn.ID.ToString() + ",") > -1)
        {
            this.txtseatnumber.Text = this.txtseatnumber.Text.Replace(btn.ID.ToString() + ",", "");
        }
        else
        {
            this.txtseatnumber.Text = this.txtseatnumber.Text.Replace(btn.ID.ToString(), "");
        }
        //numseats++;
        //numSeats.Text = numseats.ToString();
        HttpContext.Current.Session["numseats"] = Convert.ToInt32(HttpContext.Current.Session["numseats"]) + 1;
        numSeats.Text = Convert.ToInt32(HttpContext.Current.Session["numseats"]).ToString();


    }
    else if (btn.ImageUrl == "~/Image/available_seat_img.gif")
    {
        this.seattable.Visible = true;
        btn.ImageUrl = "~/Image/selected_seat_img.gif";
        if (this.txtseatnumber.Text.Trim().Length == 0)
        {
            this.txtseatnumber.Text = btn.ID.ToString();
        }
        else if (this.txtseatnumber.Text.Trim().EndsWith(","))
        {
            this.txtseatnumber.Text = this.txtseatnumber.Text + btn.ID.ToString();
        }
        else
        {
            this.txtseatnumber.Text = this.txtseatnumber.Text + "," + btn.ID.ToString();
        }
        //numseats--;
        //numSeats.Text = numseats.ToString();
        HttpContext.Current.Session["numseats"] = Convert.ToInt32(HttpContext.Current.Session["numseats"]) - 1;
        numSeats.Text = Convert.ToInt32(HttpContext.Current.Session["numseats"]).ToString();
    }


}

protected void s1_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s1);
}

protected void s2_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s2);
}

protected void s3_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s3);
}

protected void s4_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s4);
}

protected void s5_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s5);
}

protected void s6_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s6);
}

protected void s7_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s7);
}

protected void s8_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s8);
}

protected void s9_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s9);
}

protected void s10_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s10);
}

protected void s11_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s11);
}

protected void s12_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s12);
}

protected void s13_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s13);
}

protected void s14_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s14);
}

protected void s15_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s15);
}

protected void s16_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s16);
}

protected void s17_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s17);
}

protected void s18_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s18);
}

protected void s19_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s19);

}

protected void s20_Click(object sender, ImageClickEventArgs e)
{
    this.seatClick(this.s20);
}



protected void Button1_Click(object sender, EventArgs e)
{
    // Summary.seats = txtseatnumber.Text;
    HttpContext.Current.Session["seats"] = txtseatnumber.Text;
    Response.Redirect("/Admin/TransSummary.aspx");
    base.OnLoad(e);
}

protected void Button2_Click(object sender, EventArgs e)
{
    Response.Redirect("/Admin/TransSample.aspx");
    base.OnLoad(e);
}
}
            string add = "set identity_insert ticketing off;insert into ticketing(seat,customerID,tripID,reservationdate,fare) values('" + (string)HttpContext.Current.Session["seats"] + "',(select distinct customerID from customer where email = '" + (string)HttpContext.Current.Session["cusEmail"] + "'),(Select distinct tripID from trip where terminal = '" + (string)HttpContext.Current.Session["origin"] + "' and destination = '" + (string)HttpContext.Current.Session["destination"] + "'),GETDATE()," + totalfare + ")";