C#中IF判断条件失效,也不报错,找不出来原因 。直接执IF里面语句,ELSE不起作用。什么不输也添加成功!
if(TextBox1.Text!=null&&TextBox2.Text!=null&&TextBox3.Text!=null){SqlCommandadd=newSq...
if (TextBox1.Text != null && TextBox2.Text != null && TextBox3.Text != null)
{
SqlCommand add = new SqlCommand("insert into room_info values ('" + TextBox2.Text + "','" + TextBox1.Text + "','" + TextBox3.Text + "')", con);
add.ExecuteReader();
Response.Write("<script language=javascript>alert('添加成功');window.window.location.href='min.aspx';</script> ");
}
else
{
Response.Write("<script language=javascript>alert('房间名、房间号或座位数为空,重新输入!');window.window.location.href='min.aspx';</script> ");
} 展开
{
SqlCommand add = new SqlCommand("insert into room_info values ('" + TextBox2.Text + "','" + TextBox1.Text + "','" + TextBox3.Text + "')", con);
add.ExecuteReader();
Response.Write("<script language=javascript>alert('添加成功');window.window.location.href='min.aspx';</script> ");
}
else
{
Response.Write("<script language=javascript>alert('房间名、房间号或座位数为空,重新输入!');window.window.location.href='min.aspx';</script> ");
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询