asp.net问题,为什么没有先执行response.write?
if(TextBox1.Text==null){Response.Write("<script>javascript:alert('表名不能为空!')</script>"...
if (TextBox1.Text == null)
{
Response.Write("<script>javascript:alert('表名不能为空!')</script>");
}
else
{
string sqlstr = string.Format("if not exists(select * from sysobjects where name like '%" + TextBox1.Text + "%') use hdb;create table " + TextBox1.Text + "([" + TextBox2.Text + "] varchar(50) primary key)");
SqlConnection con = new SqlConnection("server=(Local);database=hdb;uid=sa;pwd=sa@123");
con.Open();
SqlCommand cmd = new SqlCommand(sqlstr, con);
cmd.ExecuteNonQuery();
Page.RegisterClientScriptBlock("", "<script defer>alert('添加成功!');</script>");
con.Close();
Label1.Text += TextBox1.Text;
Label2.Text += TextBox2.Text + ",";
代码,我在textbox1中不输入值,系统不执行IF语句,直接进入下面数据库代码,什么原因?? 展开
{
Response.Write("<script>javascript:alert('表名不能为空!')</script>");
}
else
{
string sqlstr = string.Format("if not exists(select * from sysobjects where name like '%" + TextBox1.Text + "%') use hdb;create table " + TextBox1.Text + "([" + TextBox2.Text + "] varchar(50) primary key)");
SqlConnection con = new SqlConnection("server=(Local);database=hdb;uid=sa;pwd=sa@123");
con.Open();
SqlCommand cmd = new SqlCommand(sqlstr, con);
cmd.ExecuteNonQuery();
Page.RegisterClientScriptBlock("", "<script defer>alert('添加成功!');</script>");
con.Close();
Label1.Text += TextBox1.Text;
Label2.Text += TextBox2.Text + ",";
代码,我在textbox1中不输入值,系统不执行IF语句,直接进入下面数据库代码,什么原因?? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询